Reputation: 234
In my app I have a showPauseMenu
method that pause the director and shows my pause menu. What I would like is to have this method automatically called when the app enters the background (when the person receives a phone call, hits the home button, etc.). I believe I'm going to have to use a class method or something like that. Any ideas?
Update: I now have the method successfully being called upon the app re-entering the foreground. The director gets paused but my menu to unease never shows up. My menu is a CCLayer that while the app is in the foreground is off-screen. So in the pauseGameLayer
I simply set the pauseMenuLayer.position = ccp(0,0);
and pause the director. Like I said the director gets paused but the layer doesn't move to the new position.
Upvotes: 1
Views: 586
Reputation: 234
To best solve my problem of having a pause menu pop up on its own when the app enters the background, this is what I did. I first set up a variable (isPlaying
) in my singleton class. If the app was about to enter the background (I used applicationWillResignActive
in the AppDelegate) isPlaying
was set to TRUE
. In my update function within the game would check to see if isPlaying
was set to TRUE
and as soon as it was it would launch the the function to display the pause menu. Hope this helps!
Upvotes: 0
Reputation: 3592
You want to implement the message applicationWillResignActive
in your app delegate.
See:
and
Upvotes: 1