简体   繁体   English

Home按下时使用CCGLView的EXC_BAD_ACCESS

[英]EXC_BAD_ACCESS using CCGLView when Home pressed

I use CCGLView in cocos2d2.0 to work with cocoa Touch. 我在cocos2d2.0中使用CCGLView来处理cocoa Touch。 But my application will crash when I press home button. 但是当我按下主页按钮时,我的应用程序会崩溃。 The error occured in CCGLView swapBuffers method: CCGLView swapBuffers方法中发生错误:

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

The stack is: 堆栈是:

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

6-[CCGlView swapBuffers] 6- [CCGlView swapBuffers]

7-[CCDirectorIOS drawScene] 7- [CCDirectorIOS drawScene]

8-[CCDirectorDisplayLink mainLoop:] 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
}

I resolved this issue by pausing the animation in the background in the AppDelegate 我通过在AppDelegate暂停动画来解决这个问题

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [_glView stopAnimation];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [_glView startAnimation];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM