我正在使用 LibGDX 制作启动画面(用于我的游戏)。我正在使用 .png 格式的图像,并且其中很少 - 它可以工作(我的图像正确位于资产文件夹中)我遇到了这个错误,我想使用的图像很少:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: devlogo.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.GLTexture.createTextureData(GLTexture.java:185)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:103)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:95)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:91)
at com.GunRun.Screens.Splash.show(Splash.java:34)
at com.badlogic.gdx.Game.setScreen(Game.java:61)
at com.mynewgame.game.GunRun.create(GunRun.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: java.io.IOException: Error loading pixmap: decoder init failed for stream
at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.<init>(Gdx2DPixmap.java:57)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:138)
... 10 more
闪屏类的代码:
public class Splash implements Screen{
private Sprite devlogo;
private SpriteBatch batch;
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
devlogo.draw(batch);
batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void show() {
batch = new SpriteBatch();
Texture texture = new Texture("devlogo.png");
devlogo = new Sprite(texture);
devlogo.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void hide() {
}
@Override
public void dispose() {
}
}
使用的图像具有 24 位深度,而其他没有 64 位深度的图像会有问题吗?