How to implement pause / resume in cocos2d game?

My question is to look for a design solution for pause / resume states (including all data information that needs to be saved) while playing cocos2d.

Including the following cases, but not limited to:

one). The user selects quit, and then displays a single dialog box for the user to select "quit directly", "pause";

2). Someone calls, opens a dialogue for the user to select "exit" or "pause" the game.

If you select "pause", everything that deserves to be saved must be saved. As in PC games.

I know that the director provides a β€œpause”, β€œresume”, is this normal for this task?

Thanks for any tips or comments.

Welcome for further discussion by email: apple.dev.sh@gmail.com

+6
iphone save cocos2d-iphone resume
source share
1 answer

Here is a good example:

To pause:

- (void) applicationDidEnterBackground:(UIApplication *)application { [[CCDirector sharedDirector] stopAnimation]; [[CCDirector sharedDirector] pause]; } - (void)applicationWillResignActive:(UIApplication *)application { [[CCDirector sharedDirector] stopAnimation]; [[CCDirector sharedDirector] pause]; } 

Upon renewal:

 - (void)applicationDidBecomeActive:(UIApplication *)application { [[CCDirector sharedDirector] stopAnimation]; // call this to make sure you don't start a second display link! [[CCDirector sharedDirector] resume]; [[CCDirector sharedDirector] startAnimation]; } 
+28
source share

All Articles