一些游戏重置后,Scene2d表在一部手机上变黑 [英] Scene2d tables turn black on one phone after a few game resets

查看:108
本文介绍了一些游戏重置后,Scene2d表在一部手机上变黑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的游戏屏幕同时使用Scene2d和普通的libgdx精灵.我将Scene2d用于包含一些表和文本按钮的暂停菜单.在电脑上一切正常.在正在测试游戏的两部手机上也都可以,但在第三部手机上却有铅.重新启动一两个游戏级别之后,似乎应该在屏幕上显示的所有scene2d元素都变黑了.它们仍然是响应式的,这意味着按钮可以执行应有的操作,它们可以旋转并正确执行,但是它们都是黑色的.这可能是什么问题?我在PC或其他手机上没有此PB.

My game screen uses both Scene2d and normal libgdx sprites. I use scene2d for the pause menus which contain some tables and textbuttons. All is ok on the pc. All is ok also on two mobile phones I'm testing the game on, but I have a pb on a third phone. It seems that after a restart or two of the game level all the scene2d elements that are supposed to appear on the screen have turned black. They are still responsive, meaning the buttons do what they are supposed to do, they move rotate and execute properly but they are all black. what could be the issue here? I don't have this pb on the pc or on the other phones.

推荐答案

您所描述的是在OpenGL上下文的重置过程中使用纹理的症状.您的应用程序在Libgdx纹理对象中包含指向OpenGL状态的指针,并且当OpenGL设备移交给另一个应用程序时,您的指针就变得过时了.

What you describe is a symptom of using a texture across a reset of the OpenGL context. Your app contains pointers, in the Libgdx Texture objects, into OpenGL state, and when the OpenGL device is given over to another app, your pointers become stale.

LibGDX通常可以很好地完成简单的重置之间的状态恢复,但是有几种方法可以引起问题.最常见的做法是(1)将LibGDX OpenGL状态(例如Texture)存储到static属性中. JVM 将在应用程序实例之间重用,因此LibGDX无法判断该静态对象已过时.参见 http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/了解有关如何触发不同生命周期的详细信息.

LibGDX generally does a good job of restoring state across simple resets, but there are several ways to cause problems. The most common is to (1) store LibGDX OpenGL state (e.g., a Texture) into a static property. The JVM will get reused across application instances, so LibGDX cannot tell that this static object has become stale. See http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/ for details on how to trigger the different lifecyles.

请参见在游戏中,如果我从窗口小部件运行,则图像会在Android设备上消失,但第一次安装APK时不会消失 Android静态对象生命周期

这篇关于一些游戏重置后,Scene2d表在一部手机上变黑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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