私は自分のプレーヤークラスに次のコードを持っています:
public class Player {
private static Image front;
int posX = 400;
int posY = 300;
public void player() throws SlickException{
init(null, null);
render(null, null, null);
update(null, null, (Integer) null);
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
front = new Image("res/steveFront.png");
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
front.draw(posX, posY);
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
}
}
そして、これは私のメインのゲームクラスです:
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
map.render(gc, sbg, g);
player.render(gc, sbg, g);
}
コードを実行すると、javanullpointer 例外が呼び出されます。
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
front.draw(posX, posY);
}
なぜこれを行うのですか?私は今、何時間もこれを理解しようとしています。どんな助けでも大歓迎です!