我在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 swapBuffers]
7- [CCDirectorIOS drawScene]
8- [CCDirectorDisplayLink mainLoop:]
.....
顺便说一句,我确实按照委托方式暂停导演:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] pause];
}
有什么想法吗?感谢。
答案 0 :(得分:7)
我的解决方案
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] pause];
[[CCDirector sharedDirector] stopAnimation]; // Add
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] startAnimation]; // Add
}
答案 1 :(得分:0)
我通过在AppDelegate
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[_glView stopAnimation];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[_glView startAnimation];
}