This is the error
java.lang.NullPointerException
at Miniship.fire(Miniship.java:23)
at Miniship.act(Miniship.java:10)
at greenfoot.core.Simulation.actActor(Simulation.java:568)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:526)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
This is the class that needs to be fixed
import greenfoot.*; import greenfoot.Actor; public class Miniship extends Actor { private int timer = 0; public void act() { move(4); fire(); reduceTime(); randomTurn(); turnAtEdge(); } public void fire() { if (timer == 0) { Actor laser = getOneObjectAtOffset(0,0,Redlaser.class); int rot = getRotation(); if (rot!=0) laser.setRotation(rot); timer = 60; Greenfoot.playSound("laser.wav"); } } public void reduceTime() { if (timer > 0) timer--; } /** * With a 10% probability, turn a bit right or left. */ public void randomTurn() { if ( Greenfoot.getRandomNumber(100) < 10 ) { turn( Greenfoot.getRandomNumber(40)-20 ); } } /** * If we reach the edge of the world, turn a little bit. */ public void turnAtEdge() { if (atWorldEdge()) { turn(7); } } public boolean atWorldEdge() { if(getX() < 10 || getX() > getWorld().getWidth() - 10) return true; if(getY() < 10 || getY() > getWorld().getHeight() - 10) return true; else return false; } }