7

我在 cocos2d2.0 中使用 CCGLView 来处理 cocoa Touch。但是当我按下主页按钮时,我的应用程序会崩溃。CCGLView swapBuffers 方法出现错误:

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

堆栈是:

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

6-[CCGlView 交换缓冲区]

7-【CCDirectorIOS drawScene】

8-[CCDirectorDisplayLink 主循环:]

......

顺便说一句,我确实在委托方法处暂停了导演:

- (void)applicationDidEnterBackground:(UIApplication *)application
{

    [[CCDirector sharedDirector] pause];
}

有任何想法吗?谢谢。

4

2 回答 2

7

我的解决方案

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

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[CCDirector sharedDirector] resume];   
    [[CCDirector sharedDirector] startAnimation]; // Add
}
于 2014-01-09T01:04:33.643 回答
0

我通过在后台暂停动画解决了这个问题AppDelegate

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

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [_glView startAnimation];
}
于 2015-01-28T11:04:11.563 回答