1

I am developing an iOS game; I am using several SKScenes and a single View Controller and my menu navigates between the different SKScenes. I'm having a problem with pausing (my game is using SKActions):

Problem: Suppose my game is in a 'paused' state (all SKActions of objects in my game are paused). When I click the 'home' button and send my app to the background, everything remains paused as it should. However, when I click my app to resume it, the scene that should be paused automatically 'resumes' itself, and all the SKActions resume to completion, and then the game pauses after this. (Please let me know if I can provide any additional details).

'Evidence': I know this because in the 'update' loop called every frame I have an NSLog statement that prints when the SKNode nodeGamePlay is paused, and it prints several times (half a second) when I click my game on the simulator's background.

What I want: When the app is clicked and opens, I want my pause-game-menu to appear, and I want my game (children of nodeGamePlay) to be paused.

What I have: In my SKScenePlay, I have a method that loads a 'pause menu' (not a child of nodeGamePlay) and pauses nodeGamePlay, which displays when a user clicks the pause button. Currently, when the user sends my app to the background and then reopens it, this method is called and the pause menu is added and the nodeGamePlay SHOULD GET paused (I call it with the following in my only viewController). However, although the pause menu displays, the nodeGamePlay does not get paused. How can I fix this?

- (void)appDidBecomeActive:(NSNotification *)notification {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"loadPauseGameMenu" object:scene];
}

EDIT: Update, when I set self.paused=true (for the SKScene), everything pauses correctly. When I do a for-in loop for each child in self and set each child.paused=true, SKActions are not paused correctly.

user3797886
  • 339
  • 1
  • 3
  • 16
  • It's pretty clear what you want but your code is a NSNotification... not sure how that is used by your code and what relevance it has to your issue. You also make no mention if this code snippet in your question. – sangony Mar 28 '15 at 23:13
  • I answered this here: http://stackoverflow.com/q/27576448/1015571 – hamobi Mar 29 '15 at 00:13

0 Answers0