我使用 AssetManager 来管理 libgdx 游戏中的资源。我有静态图像和动画。当我使用模拟器(Nexus 6,Api 29)测试游戏时,一切都很好,但是当我将游戏模拟到我的真实手机(Samsung J5 2016,Api 25)时,它开始显示黑色矩形而不是一些动画,但静态纹理很好。
我的动画是 800x800 像素,10 fps。
这是此类纹理的示例。此代码位于加载屏幕中:
assetManager.load(AssetDescriptors.BONUS_TEXTURE);
这里我实例化动画,帧时间= 0.1f。此代码位于工厂中,用于创建具有以下动画的对象:
animationComponent.animation = new Animation<>(GameData.FRAME_TIME,
assetManager.get(AssetDescriptors.BONUS_TEXTURE).getRegions());
我把它画在这里。这是来自管理渲染的类:
batch.draw(animationComponent.animation.getKeyFrame(animationComponent.elapsedTime, true),
position.x - dimension.width / 2f, position.y - dimension.height / 2f,
dimension.width, dimension.height
);
这适用于模拟器,但不适用于真实设备。请告诉我可能出了什么问题。感谢您的帮助。
phone - player, pot and gran animations phone - gran and pot animations
最佳答案
许多设备不支持尺寸不是 2 的幂的纹理。您应该使用TexturePacker 打包纹理并保持pot
设置为打开状态。
关于java - LibGDX:黑色矩形而不是动画纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56890360/