libGDX iOS主页按钮杀死游戏(libGDX iOS home button kills the game)

编程入门 行业动态 更新时间:2024-10-28 21:24:32
libGDX iOS主页按钮杀死游戏(libGDX iOS home button kills the game)

我正在为Android和iOS开发一个libGDX游戏(MobiDevelop的RoboVM fork)。 Android完美工作,但我在iOS上遇到问题。 当按下iPhone主页按钮离开游戏时,我通过点击图标再次启动游戏,游戏不会从暂停的位置恢复,而是重新启动,这意味着显示加载屏幕,重新加载所有资产,出现主菜单。 就像一个新的/新的应用程序的开始。 我的libgdx项目中没有针对iOS模块的特定配置,并且正在使用预生成的模块。

是否有可能告诉iOS我不想杀死这个进程? 我只想切换到暂停/休眠模式。

I'm developing a libGDX game for Android and iOS (MobiDevelop's RoboVM fork). Android works perfectly, but I have a issue on iOS. When the iPhone home button is pressed to leave the game, and I launch the game again by tapping on icon, the game does not resume from where it was paused, but instead restarts, which means the loading screen is displayed, all assets are reloaded, and the main menu appears. Like a fresh/new start of the app. I do not have any specific configuration for the iOS module in my libgdx project and am using what was pregenerated.

Is it possible to tell iOS that I do not want to kill the process? I want to switch to pause/sleeping mode only.

最满意答案

我发现了这个问题的原因。 我在真实设备上测试过它,因此我无法看到日志。 当我切换到模拟器并查看日志时,发现一个NullPointerException 。 这是应用程序崩溃的原因。 当我修复这个错误时,一切都按照我的预期工作。 按下iPhone主页按钮后,调用com.badlogic.gdx.Screen的pause()方法,并在重新运行游戏后,从其停止/暂停的位置继续。

我吸取了教训:首先在模拟器上进行测试:-)

I found a reason of this problem. I tested it on the real device, therefore I was unable to see a logs. When I switch to simulator and look at the logs, I found a NullPointerException. This was a cause of application crash. When I fix this bug, everything works as I expected. After iPhone home button is pressed, pause() method of com.badlogic.gdx.Screen is called and after rerun the game, it continues from exactly where it stops / pauses.

I learned a lesson: make a tests on simulator at first :-)

更多推荐

本文发布于:2023-07-23 22:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1238166.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   主页   游戏   iOS   libGDX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!