我正在尝试绘制图像,但我遇到了问题。这是代码:
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0,0,0,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
splash.draw(batch);
batch.end();
}
@Override
public void show() {
Texture splashTexture = new Texture("/img/intrologo.png");
splash = new Sprite(splashTexture);
splash.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
我正在尝试在桌面上运行它。窗户跑了!但是我在控制台中遇到了很多错误。他们来了:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: assets/img/intrologo.png
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: assets/img/intrologo.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:175)
at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:118)
at com.eamonn.blackpoint2.screens.splash.show(splash.java:32)
at com.badlogic.gdx.Game.setScreen(Game.java:62)
at com.eamonn.blackpoint2.Blackpoint2.create(Blackpoint2.java:12)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:127)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: assets/img/intrologo.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:127)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:580)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:215)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 11 more
我在 LibGDX 论坛上问过这个问题,但几天后我没有得到任何关于帮助的回复。就像是故意被忽视一样。
文件“intrologo.png”确实存在,它实际上出现在 Eclipse 中!
我也关不上窗户。我不得不强行退出窗口,这让我很紧张:(
谢谢!任何帮助表示赞赏!