简体   繁体   English

LibGDX:黑色矩形而不是动画纹理

[英]LibGDX: black rectangles instead of animation textures

I use AssetManager to manage assets in my libgdx game. 我使用AssetManager来管理libgdx游戏中的资产。 I have static images and animations. 我有静态图像和动画。 When I used emulator (Nexus 6, Api 29) to test the game it was fine, but once I emulated the game to my real phone (Samsung J5 2016, Api 25) it started showing black rectangles instead of some animations, but static textures were fine. 当我使用模拟器(Nexus 6,Api 29)测试游戏时,还不错,但是一旦我将游戏模拟到我的真实手机(Samsung J5 2016,Api 25)上,它便开始显示黑色矩形,而不是某些动画,但带有静态纹理我们很好。

My animations are 800x800 px, 10 fps. 我的动画是800x800 px,10 fps。

Here is an example of such texture. 这是这种纹理的一个例子。 This code is in Loading screen: 此代码在“加载”屏幕中:

assetManager.load(AssetDescriptors.BONUS_TEXTURE);

Here I instantiate animation, frame time = 0.1f. 在这里我实例化动画,帧时间= 0.1f。 This code is in factory, that creates the object with such animation: 此代码在工厂中,使用以下动画创建对象:

animationComponent.animation = new Animation<>(GameData.FRAME_TIME,
                assetManager.get(AssetDescriptors.BONUS_TEXTURE).getRegions());

And here I draw it. 在这里我画它。 This is from the class that manages rendering: 这来自于管理渲染的类:

batch.draw(animationComponent.animation.getKeyFrame(animationComponent.elapsedTime, true),
                position.x - dimension.width / 2f, position.y - dimension.height / 2f,
                dimension.width, dimension.height
        );

This works on emulator and doesn`t work on real device. 这适用于模拟器,不适用于真实设备。 Please tell me what can be wrong. 请告诉我有什么问题。 Thank you for your help. 谢谢您的帮助。

emulator emulator 模拟器 模拟器

phone - player, pot and gran animations phone - gran and pot animations 电话-播放器,锅和格兰动画电话-播放器,锅和格兰 动画

Many devices don't support textures with dimensions that are not a power of two. 许多设备不支持尺寸不是2的幂的纹理。 You should pack your textures with TexturePacker and keep the pot setting on. 您应该使用TexturePacker包装纹理,并保持pot设置为开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM