I need some help!! I'm making a game where you fire arrows at babies. But if they touch you, a game over screen appears. When I touch a baby, a terminal window appears. it looks like this:
java.lang.NullPointerException
at BadGuy.defeat(BadGuy.java:86
at BadGuy.act(BadGuy.java:31)
at Minions.act(Minions.java:18)
at greenfoot.core.Simulation.actActor(Simulation.java:507)
if you need more, I'll post the rest.
Here's my BadGuy Act method:
public void act (int arrows, int score)
TargetWorld world = (TargetWorld)getWorld();
if(getOneIntersectingObject(FireArrow.class0 != null)
}world.addArrows(arrows);
world.addScore(score);
world.removeObject(this);
return;
{
move();
checkPlatformFall();
defeat();
}
And now the defeat method:
Public void defeat()
{
TargetWorld world = (TargetWorld)getWorld();
if(getOneIntersectingObject(Man.class))
{
JOptionPane.showMessageDialog(null, "Game Over!/nScore: " + score.getScore;
At the top I put
Import javax.swing.JOptionPane;
and
private Score score;
If anybody knows what to do please respond!
}
}