位置: 编程技术 - 正文
推荐整理分享cocos2dx onpause崩,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
原文: encountered a crash issue that, when you tried to install apk and start it from Eclipse, the game will surely crash with an assertion error if your phone’s screen is off. Here is the reason I found:When the phone screen is off, android will call onCreate, onResume, then onPause in order. While in onPause, Cocos2dxRenderer.nativeOnPause will be called. So see the code below:
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() {CCApplication::sharedApplication()->applicationDidEnterBackground();CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL);}
Cocos2dxRenderer.nativeOnPause will attempt to call applicationDidEnterBackground() of the current application. But it is NULL: because while the screen is off, android won’t draw anything so that Cocos2dxRenderer.nativeInit isn’t called, and AppDelegate won’t be created.But why the app don’t crash in onResume? I compared the native code of Cocos2dxRenderer.onResume:
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {if (CCDirector::sharedDirector()->getOpenGLView()) {CCApplication::sharedApplication()->applicationWillEnterForeground();}}
I found a check before calling applicationWillEnterForeground(), this prevent calling applicationWillEnterForeground() while the application is not created.
I wonder why the implementation won’t check getOpenGLView() in onPause but in onResume only?
The issue above won’t effect much for the end-user, because they always launch your game with screen on. But it might lead to crash on some auto test system…
cocos2dx3.2 xcode中资源路径设置问题 在xcode中,将资源分类,然后将各自的文件夹添加到Resources,运行程序的时候老是报错,说是找不懂资源,原因就是找不到资源路径。那么如何设置呢?1
Bullet(Cocos2dx)之封装PhysicsWorld3D Bullet3之封装PhysicsWorld3D根据bullet3HelloWorld程序去封装一个PhysicsWorld3D,首先应该去创建一个物理世界,而对于一个物理世界,默认都有重力,提供一个创
浅谈cocos2dx手游开发CPU发热严重之见 猜测它有可能是在主循环里使用了Sleep(0),一搜,果然定位到具体代码,它位于cocos2dxplatformwinCCApplication.cpp,大致长像如下:1while(1){2if(有消息){3if(时
上一篇:cocos2dx 3.2 读写XML,基于tinyxml2封装的易使用,更灵活的XML接口。中文国际化。(cocos creator读取json)
下一篇:cocos2dx3.2 xcode中资源路径设置问题
友情链接: 武汉网站建设