When i shoot at the Missile it comes up with error
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Astroid here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Missile extends Objects {
Scoreboard Scoreboard;
boolean touchingMissile;
public Missile(Scoreboard pointScoreboard) {
Scoreboard = pointScoreboard;
}
public void act() {
movement();
makeMissile();
removeMissile();
}
/**
* The movement and rotation for the missile.
*/
private void movement() {
int x = getX() -3;
int y = getY();
setLocation(x, y);
}
/**
* If the missile is at the edge of the world or is hit by a bullet shot
* it will be removed and it will create a new missile. Also randomly
* creates missile
*/
public void makeMissile() {
World world = getWorld();
Missile newMissile = new Missile(Scoreboard);
int worldHeight = world.getHeight();
int worldWidth = world.getWidth();
if(Greenfoot.getRandomNumber(9999) < 9) {
world.addObject(newMissile, worldWidth, Greenfoot.getRandomNumber(worldHeight));
}
}
public void removeMissile() {
World world = getWorld();
Missile newMissile = new Missile(Scoreboard);
int worldHeight = world.getHeight();
int worldWidth = world.getWidth();
if(atWorldEdge()&& this != null) {
world.removeObject(this);
world.addObject(newMissile, worldWidth, Greenfoot.getRandomNumber(worldHeight));
}
if(onContact(Bullet.class) && this != null) {
Scoreboard.add(100);
world.removeObject(this);
world.addObject(newMissile, worldWidth, Greenfoot.getRandomNumber(worldHeight));
}
}
}
