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.
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 usedapplicationWillResignActivein the AppDelegate)isPlayingwas set toTRUE. In my update function within the game would check to see ifisPlayingwas set toTRUEand as soon as it was it would launch the the function to display the pause menu. Hope this helps!