gpt4 book ai didi

java - 无法加载简单图像。 Libgdx

转载 作者:行者123 更新时间:2023-11-30 03:28:11 25 4
gpt4 key购买 nike

我正在使用 LibGDX 制作启动画面(为我的游戏)。我正在使用 .png 格式的图像,并且其中很少有 - 它可以工作(我的图像正确位于 Assets 文件夹中)我想使用的一些图像出现此错误:

    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 位深度,会出现问题吗?

最佳答案

就我而言,我必须以 8 位/ channel 而不是 16 位/ channel 保存图像。

关于java - 无法加载简单图像。 Libgdx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29685437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com