Slick2D - Cannot instantiate the type Image
- by speakon
I am getting this strange error and I cannot for the life of me figure out why:
Cannot instantiate the type Image
CODE:
import java.awt.Image;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class MainMenuState extends BasicGameState {
int stateID = -1;
Image background = null;
Image startGameOption = null;
Image exitOption = null;
float startGameScale = 1;
float exitScale = 1;
MainMenuState( int stateID )
{
this.stateID = stateID;
}
public int getID() {
return stateID;
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
try {
background = new Image("data/menu.jpg");
Image menuOptions = new Image("data/menuoptions.png");
startGameOption = menuOptions.getSubImage(0, 0, 377, 71);
exitOption = menuOptions.getSubImage(0, 71, 377, 71);
}catch (SlickException e) {
System.err.print(e);
}
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
}
}
Why do I get this error? I've googled endlessly and nobody else has it, this worked fine in my other game. Any ideas?