在游戏中,如果我从小部件运行,Android设备上消失,但是当我第一次安装apk时,图像不会消失 [英] In game Images disappear on Android device if i run from widget, but not when I install apk first time

查看:155
本文介绍了在游戏中,如果我从小部件运行,Android设备上消失,但是当我第一次安装apk时,图像不会消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用LibGDX创建了一个游戏,在我的电脑上工作正常。
我通过Gradle视图在Android Studio中创建了一个调试.apk - > Build&然后复制我的android-debug.apk& android-debug-unaligned.apk到我的Android设备的下载文件夹。



现在,当我的Android设备上点击了我的一个文件,设备问我是否想安装它并选择是,随后我打开我的游戏,它运行正常。



现在,当我相当的游戏,并尝试从小部件重新启动游戏,安装完成后,我的Android-桌面(主屏幕上可以点击所有的应用程序)。



如果我从窗口小部件启动它,我的图形是搞砸了我不知道为什么?
从闪屏上缺少徽标图像。切换到MenuScreen时,图像丢失。当我切换到我的游戏画面时,图形完全搞砸了。



当我重新安装游戏并再次运行时,没有问题。

如果有人可以帮忙?

解决方案

使用情况的区别是状态的运行您的应用程序的JVM。在某些情况下,JVM是全新的,一切正常。但是,如果JVM被回收(因为Android没有杀死它,只是把它放在后台),你遇到问题。问题的核心在于您重新启动应用程序时(例如OpenGL纹理ID在后续运行中被使用),很有可能是从上一次运行时引用OpenGL状态。因为OpenGL是一个有状态的驱动程序,当应用程序的状态丢失上下文时,它将被擦除,您需要重新加载全局OpenGL状态。



请参阅Android静态对象生命周期,以了解基础问题的描述和 http://bitiotic.com/blog/2013/05/23/libgdx-and-android - 应用生命周期/ 针对一些关于诊断和处理的具体的libgdx特定提示。


I created a game in with LibGDX, which works fine on my computer. I created a debug .apk in Android Studio via the Gradle View -> Build & then copied my android-debug.apk & android-debug-unaligned.apk to the download folder of my Android Device.

Now when on my android device I clicked on one of my files the device ask if I wanna install it and choose yes and subsequently I open my game and it run fine.

Now the porblem occurs when i quite the game and try to restart the game from the widget that after the installation has been put on my android-"desktop" (main screen with all the apps you can click).

If i start it from the widget my graphics are messed up and missing & i have no idea why? Logo image missing from splashscreen. When switching to MenuScreen the image there is missing. And when I switch to my game screen graphics get totally messed up.

When i re-install the game and run it again, there is no problem.

If anyone could help?

解决方案

The difference in your use cases is the state of the JVM that is running your application. In some cases the JVM is brand new, and everything works. However, if the JVM is recycled (because Android hasn't killed it, just put it in the background), you run into problems. The core of the problem is, most likely, that you have references to OpenGL state from the previous run when you re-start the application (e.g., OpenGL texture IDs from the first run are getting used on subsequent runs). Because OpenGL is a stateful driver, and an application's state is wiped when it loses context, you need to reload global OpenGL state.

See Android static object lifecycle for a description of the underlying problem and http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/ for some Libgdx-specific tips on diagnosing and dealing with it.

这篇关于在游戏中,如果我从小部件运行,Android设备上消失,但是当我第一次安装apk时,图像不会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆