我的 cocos2d-x 游戏在进入后台时崩溃。这是来自 AppDelegate 的一些代码:
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
CCUserDefault::sharedUserDefault()->flush();
CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
CocosDenshion::SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
和错误信息:
libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
0x3797e094: trap
0x3797e096: nop
请注意,它总是在 iPhone 上崩溃,但在 Android 上 99% 崩溃(好吧,当游戏没有加载大图像等时)
编辑:我已经尝试过 CCDirector::sharedDirector()->stopAnimation() 并且它适用于 iOS。但 Android 仍然崩溃(不是立即崩溃。返回应用程序时,屏幕变黑(但我认为它仍在运行,因为背景音乐仍在播放。然后大约 5 秒后它崩溃了)
编辑 2: Eclipse 中的错误消息:
libEGL call to OpenGL ES API with no current context (logged once per thread) (red warning text)
libc Fatal signal 11 (SIGSEGV) at 0x5f012000 (code=2) (black text)