Bug #435 Fix

Device: 3GS
Device iOS: 4.1 (8B117)
Xcode version: 3.2 (10M2423)
Mac OS X: 10.6: (10M2423)
iPhone OS: 4.2: (8C134)

added ios/testsAppDelegate.mm

  • (void)applicationWillResignActive:(UIApplication *)application {
    cocos2d::CCDirector::sharedDirector()~~>pause;
    }

~~ (void)applicationDidEnterBackground:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()~~>stopAnimation;
}

~~ (void)applicationWillEnterForeground:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()~~>startAnimation;
}

~~ (void)applicationDidBecomeActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->resume();
}

Removed assertion for CCDirector::setAnimationInterval(double value)

at line 269

Hope it helps

Thanks! It do works!
And I just checked cocos2d-iphone 0.99.5, your sources are the same as AppDelegate.m in it.
But I can’t quite understand why invoking CCDirector methods can affects CocosDenshion? They’re two independent libraries.

Hello:

The error I got originally:

“sgx error (background gpu access not permitted)”

Indicated something is trying to access the gpu while the app is in background, such an access is prohibited, according to Apple:

Sorry to say, but I am not sure why the pause/resume from the CCDirector has something to do with SimpleAudioEngine, since pause/resume inside the CCDirector do not pause/resume the audio engine, nor audio engine depends on it.

Just found out a thread here:

http://www.cocos2d-iphone.org/forum/topic/7163

It seems like they were not sure why either.