Fast play will not be paused

I find it difficult to pause the game when I leave and return to it.

I am trying to suspend an SKSpriteNode called main that contains all my sprites when the view comes back from the background. In a game, I can press the pause button and the game pauses and the resume button resumes.

This is my code:

func didBecomeActive() {
    println("didBecomeActive")
    main.paused = true
}

      

The first time this is triggered is when the app is opened for the first time and everything pauses as it should. The second time it comes back from the background and all of a sudden all animations (SKActions, particles, etc.) start working.

I confirmed that this method was running and I also tried setting main.paused to false and then true and even self.paused to true. Nothing works.

I am completely stumped. Does anyone know what the problem is?

+3


source to share


1 answer


The setup self.scene.paused = YES

should fix this. I have tried this with a game I am developing and it works great.



Just set self.scene.paused = YES

when the game goes into the background, then when it comes back to the foreground it should stay paused until you resume it, i.e. Install self.scene.paused = NO

.



+2


source







All Articles