I use CCGLView in cocos2d2.0 to work with cocoa Touch. But my application will crash when I press home button. The error occured in CCGLView swapBuffers method:
if(![_context presentRenderbuffer:GL_RENDERBUFFER])
-------EXC_BAD_ACCESS
The stack is:
5:EAGLContext_presentRenderbuffer(EAGleContext*,objc_selectorr*,unsigned int)
6-[CCGlView swapBuffers]
7-[CCDirectorIOS drawScene]
8-[CCDirectorDisplayLink mainLoop:]
.....
By the way, I do pause the director at delegate method:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] pause];
}
Any ideas? Thanks.
my solution
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] pause];
[[CCDirector sharedDirector] stopAnimation]; // Add
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] startAnimation]; // Add
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With