So I tried to code my ship so that when it touches an asteroid it's going to be removed.
But when I try to run the game I get an error:
public void destruction()
{
Ship s = (Ship) getOneIntersectingObject(Ship.class);
if (s.isTouching(Asteroid.class))
{
getWorld().removeObject(this);
}
return;
}java.lang.NullPointerException
at Ship.act(Ship.java:18)
at greenfoot.core.Simulation.actActor(Simulation.java:594)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:552)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
I looked in the discuss section for answers, but couldn't find a problem that fits mine.

