SpriteKit - How to detect if SKTransition animation is finished?

Viewed 113

In my SpriteKit project I'm using SKTransition.doorOpenHorizontal() animation when I transition between scenes. In the next scene I'm using a timer inside the didMove() function to create nodes every few milliseconds. I have noticed, the node counter is increasing even though the transition animation from the previous scene is not finished yet and the scene is not updating. I would like to avoid this and run the timer to create nodes only after the transition animation is finished.

Is there any way in SpriteKit to detect if SKTransition animation is finished when we transition between scenes? Or should I just use a second timer to delay the creation of the nodes? What is the best way to go about this?

Thank you.

1 Answers

There is a property called pausesIncomingScene which will pause the incoming scene during the transition.

      let animation = SKTransition.doorsOpenHorizontal(withDuration: 1.0)
      animation.pausesIncomingScene = true

That should stop anything running in the incoming scene until the transition has finished.

Related