位置: 编程技术 - 正文

cocos2dx onpause崩

编辑:rootadmin

推荐整理分享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:

cocos2dx onpause崩

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(时

本文链接地址:https://www.jiuchutong.com/biancheng/372621.html 转载请保留说明!

上一篇:cocos2dx 3.2 读写XML,基于tinyxml2封装的易使用,更灵活的XML接口。中文国际化。(cocos creator读取json)

下一篇:cocos2dx3.2 xcode中资源路径设置问题

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络