hi im making a code where i click an actor which serves as the "play button" which calls the a method in the world which gets the value of the knight. i initiated a variable called levelType which is an integer type (0 or 1) which separates 2 worlds which are the tutorial and the actual game. everytime i press the play button, i get a null pointer exception error but the worlds still load. what do i do to solve this?
Play Button Class
World Class
public class PlayButton extends Actor
{
public PlayButton()
{
setImage("SlayButton.png");
}
public void act()
{
MainMenu mainMenu = (MainMenu) getWorld();
Knight knight = mainMenu.getKnight();
if(Greenfoot.mouseClicked(this))
{
Greenfoot.setWorld(new Level0());
knight.actualLevel();
}
}
}public class Forest1 extends World
{
public Forest1()
{
this(new Knight());
}
public Forest1(Knight knight)
{
super(600, 400, 1);
Instructions instructions = new Instructions("instructions1.png");
setBackground("forest.jpg");
addObject(new Ground("ground.png"), 300, 388);
addObject(knight, 60, 333);
addObject(instructions,295,70);
setPaintOrder(Knight.class);
}
}
