my scenario crashes
it says the mistake is somewhere in this
the error code is
java.lang.NullPointerException
at Link.restart(Link.java:59)
at Link.checkShotRock(Link.java:52)
at Link.act(Link.java:34)
at greenfoot.core.Simulation.actActor(Simulation.java:593)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:551)
at greenfoot.core.Simulation.runContent(Simulation.java:217)
at greenfoot.core.Simulation.run(Simulation.java:207)
im not good at error code analysing
what is wrong
/**
* Here you can tell your actor what he has to do.
*/
public void act()
{
checkKeyPress();
if(((desert)getWorld()).start == 1)
{
die();
}
if(((desert)getWorld()).start == 2)
{
checkShotRock();
}
}
public void checkShotRock()
{
if(canSee(shotRock.class))
{
getWorld().removeObject(this);
System.out.println("You got hit by a rock!");
System.out.println("You lose!");
restart();
}
if(canSee(octorok.class))
{
getWorld().removeObject(this);
System.out.println("You got hit by an octorok!");
System.out.println("You lose!");
restart();
}
}
public void restart()
{
((desert)getWorld()).maxScore2 = timeCounter.mins;
((desert)getWorld()).start = 0;
}
