Search code examples
iosswiftsprite-kitpause

Pause scene before transition and perform transition


I'm struggling with pause moment in my game. I want to make button which perform pause logic and transition me to another scene with save action to sceneManager that holds gameScene.

Everything works fine but I can't make pause all actions my scene has. I read quite a lot of themes but still no luck.

The only think that really pauses any movement on my scene is

self.scene.view?.isPaused = true

But it pauses my transition as well.

I have spawning enemies, power-ups, shots and background stuff. So if I translate to other scene with this code:

transition.pausesOutgoingScene = true
transition.pausesIncomingScene = true

I see that objects and actions are not paused as well!

How to get pause logic work?


Solution

  • I added all nodes I want to pause to the same SKNode instance and after that I can just write:

    someNodeWithSpritesToPause.isPaused = true
    physicsWorld.speed = 0
    

    This code solves my problem.

    Thank you!