Why do I have an error when adding states in slick?
Posted
by
SystemNetworks
on Game Development
See other posts from Game Development
or by SystemNetworks
Published on 2012-09-25T09:33:35Z
Indexed on
2012/09/25
9:49 UTC
Read the original article
Hit count: 253
When I was going to create another state I had an error. This is my code:
public static final int play2 = 3;
and
public Game(String gamename){
this.addState(new mission(play2));
}
and
public void initStatesList(GameContainer gc) throws SlickException{
this.getState(play2).init(gc, this);
}
I have an error in the addState. above the above code. I don't know where is the problem. But if you want the whole code it is here: package javagame;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "NET FRONT";
public static final int menu = 0;
public static final int play = 1;
public static final int train = 2;
public static final int play2 = 3;
public Game(String gamename){
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));
this.addState(new train(train));
this.addState(new mission(play2));
}
public void initStatesList(GameContainer gc) throws SlickException{
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.getState(train).init(gc, this);
this.enterState(menu);
this.getState(play2).init(gc, this);
}
public static void main(String[] args) {
try{
AppGameContainer app =new AppGameContainer(new Game(gamename));
app.setDisplayMode(1500, 1000, false);
app.start();
}catch(SlickException e){
e.printStackTrace();
}
}
}
//SYSTEM NETWORKS(C) 2012 NET FRONT
© Game Development or respective owner