Cocos2dx报OpenGL error 0x0506错误

近期做第三方sdk接入时,发现iOS8系统下,进行银联充值后,返回游戏有很大几率会报
OpenGL error 0x0506............
之类的绘制问题,游戏卡死,花了很长时间,一直没有头绪

最终找到这篇文章:
http://blog.lessfun.com/blog/2014/09/24/ios8-issue-keyboard-orientation-and-idletimerdisabled-not-working/

原来后台运行的app,是不允许进行openGL绘制的,而且iOS8要求更严格

好吧,切换到RootViewController.mm,加上这两个方法:
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
}


applicationDidEnterBackground主要是在切到后台时做这些:
    CCDirector::sharedDirector()->stopAnimation();
    SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
    SimpleAudioEngine::sharedEngine()->pauseAllEffects();


applicationWillEnterForeground是切回前台,做这些:
    CCDirector::sharedDirector()->startAnimation();
    SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
    SimpleAudioEngine::sharedEngine()->resumeAllEffects();


done,希望能帮到iOS8下遇到类似问题的朋友

猜你喜欢

转载自shineonly.iteye.com/blog/2155972