i recently have encountered an error when i compile my game in eclispe and it started happening this afternoon
Exception in thread "main" java.lang.NullPointerException
at javagame.Game.initStatesList(Game.java:25)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:164)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
at javagame.Game.main(Game.java:34)
Whats wrong?
Without any code or even any hint about what you're doing exactly we can't help you
When you encounter an error please post the code in which your error is occuring, mark the line of code where the code crashed, and give a description of what you're trying to do exactly.
When you encounter an error please post the code in which your error is occuring, mark the line of code where the code crashed, and give a description of what you're trying to do exactly.
package javagame;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "Bucky's World!";
public static final int menu = 0;
public static final int play = 1;
public static final int play2 = 2;
public Game(String gamename){
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));
}
public void initStatesList(GameContainer gc) throws SlickException{
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.getState(play2).init(gc, this);
this.enterState(menu);
}
public static void main(String[] args) {
AppGameContainer appgc;
try{
appgc = new AppGameContainer(new Game(gamename));
appgc.setDisplayMode(640, 360, false);
appgc.start();
}catch(SlickException e){
e.printStackTrace();
}
}
}
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "Bucky's World!";
public static final int menu = 0;
public static final int play = 1;
public static final int play2 = 2;
public Game(String gamename){
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));
}
public void initStatesList(GameContainer gc) throws SlickException{
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.getState(play2).init(gc, this);
this.enterState(menu);
}
public static void main(String[] args) {
AppGameContainer appgc;
try{
appgc = new AppGameContainer(new Game(gamename));
appgc.setDisplayMode(640, 360, false);
appgc.start();
}catch(SlickException e){
e.printStackTrace();
}
}
}
You've added two states to the list in the constructor, but in the initStatesList function you seem to be trying to initialise 3 states.
Is your intention to get rid of the JVM completely? In this case you would have to compile the Java sources to native code. I believe gcc can do that within certain limitations.
If you just want to hide the bytecode from the end user, there are several wrappers like http://launch4j.sourceforge.net/ which just fell out of Google.
If you just want to hide the bytecode from the end user, there are several wrappers like http://launch4j.sourceforge.net/ which just fell out of Google.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement