EXC_BAD_ACCESS using CCGLView when you click the Home button

I am using CCGLView in cocos2d2.0 to work with cocoa Touch. But my application will crash when I click the home button. An error occurred in the swapBuffers CCGLView method:

if(![_context presentRenderbuffer:GL_RENDERBUFFER]) ------- EXC_BAD_ACCESS

Stack:

5: EAGLContext_presentRenderbuffer (EAGleContext *, objc_selectorr *, unsigned int)

6- [CCGlView swapBuffers]

7- [CCDirectorIOS drawScene]

8- [CCDirectorDisplayLink mainLoop:]

.....

By the way, I pause the director using the delegate method:

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

Any ideas? Thanks.

+7
ios iphone cocos2d-iphone
source share
2 answers

my decision

 - (void)applicationDidEnterBackground:(UIApplication *)application { [[CCDirector sharedDirector] pause]; [[CCDirector sharedDirector] stopAnimation]; // Add } - (void)applicationWillEnterForeground:(UIApplication *)application { [[CCDirector sharedDirector] resume]; [[CCDirector sharedDirector] startAnimation]; // Add } 
+7
source share

I solved this problem by pausing the animation in the background in AppDelegate

 - (void)applicationDidEnterBackground:(UIApplication *)application { [_glView stopAnimation]; } - (void)applicationWillEnterForeground:(UIApplication *)application { [_glView startAnimation]; } 
0
source share

All Articles