This is how i did it:
To pause:
- (void) applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}
When resuming:
- (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];
}
Someone else suggested a BOOL flag to make sure you don't call animation methods twice, but I find calling stopAnimation before startAnimation does the trick just as well...
An important thing to note is that applicationDidBecomeActive: is called also when you program starts for the first time, so if you call startAnimation there, without first stopping it, or checking for "first run", then you will have two display links running and no amount of stopAnimation will save your program from crashing when it is backgrounded...