0

Hello how to make the transition

let transitionType = SKTransition.crossFadeWithDuration (2.0)

started after 5 seconds?

my code:

let nextLevel = level2(size: size)
nextLevel.scaleMode = scaleMode
let transitionType = SKTransition.crossFadeWithDuration(2.0)       
view?.presentScene(nextLevel,transition: transitionType)
ABakerSmith
  • 22,759
  • 9
  • 68
  • 78
Darci
  • 15
  • 3
  • You could use a NSTimer for that. Similar [question](http://stackoverflow.com/questions/24007518/how-can-i-use-nstimer-in-swift). – Jan Trienes Jun 10 '15 at 19:07
  • 1
    @Jan Trienes, it's not a good idea to use an `NSTimer` with Sprite Kit - http://stackoverflow.com/questions/23978209/spritekit-creating-a-timer – ABakerSmith Jun 10 '15 at 19:09

1 Answers1

2

You could use SKAction.waitForDuration combined with SKAction.runBlock in an SKAction sequence:

let wait = SKAction.waitForDuration(5)
let action = SKAction.runBlock {
    view?.presentScene(nextLevel, transition: transitionType)
}

self.runAction(SKAction.sequence([wait, action]))
ABakerSmith
  • 22,759
  • 9
  • 68
  • 78