package com.me.mygdxgame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
public class MyGdxGame implements ApplicationListener {
SpriteBatch batch;
Texture sonic;
@Override
public void create() {
batch = new SpriteBatch();
sonic = new Texture(Gdx.files.internal("Sonic_walk.png"));
}
@Override
public void dispose() {
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(sonic, 50, 50);
batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}
然后我得到这个错误,
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException:
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: Sonic_walk.png
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: Sonic_walk.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.me.mygdxgame.MyGdxGame.create(MyGdxGame.java:18)
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: Sonic_walk.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)
... 8 more
我不明白这个错误。有什么建议么?谢谢!