I have this so far, but it doesn't seem to run the gameOver() class correctly. The gameOver() class is last in my act method, just after kill(), if it matters.
public void kill() { //detects when the gun is close to an asteroid and shoots removes them both
List<Enemy1> enemies = new ArrayList<Enemy1>();
enemies = this.getObjectsInRange(25, Enemy1.class);
for (Enemy1 e : enemies) {
if (enemies.size()>0) {
dead = true;
getWorld().removeObject(enemies.get(0));
getWorld().removeObject(this);
}
}
}
public void gameOver() {
if (dead == true){
getWorld().removeObjects(getWorld().getObjects(null));
getWorld().addObject(new GameOver(), 300, 200);
Greenfoot.stop();
}
}
