Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXC_BAD_ACCESS using CCGLView when Home pressed

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.

like image 353
Ah Wen Avatar asked Oct 08 '13 06:10

Ah Wen


1 Answers

my solution

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

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[CCDirector sharedDirector] resume];   
    [[CCDirector sharedDirector] startAnimation]; // Add
}
like image 167
Kyujin Kim Avatar answered Oct 20 '22 18:10

Kyujin Kim