Slick2D - Cannot instantiate the type Image
Posted
by
speakon
on Game Development
See other posts from Game Development
or by speakon
Published on 2012-06-23T02:37:40Z
Indexed on
2012/06/23
3:24 UTC
Read the original article
Hit count: 606
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?
© Game Development or respective owner