I have a school project with Greenfoot and i need to have LittleRedCap killed by an explosion, but i cant get it to work. I also have a scoreboard which need to get a negative score so my gameover method will start. I am getting a nulpointer error and an actor not in world error.
LittleRedCap is not in contact with the explosion and still the score goes down by 100 (Before i broke it and still worked).Right now im completely lost on what to do
public void killLittleRedCap() {
Actor b = getOneIntersectingObject(LittleRedCap.class);
if( b!= null) {
Actor actor = getOneObjectAtOffset(0, 0, LittleRedCap.class);
if(actor.getWorld() != null) {
getWorld().removeObject(actor);
}
score = score - 100;
Planet planet = (Planet)getWorld();
World world = getWorld();
world.removeObjects(world.getObjects(Scoreboard.class));
world.addObject (new Scoreboard(score), 75,25);
if (score<10) {
world.addObject(new Announcement(),300,300);
Greenfoot.stop();
}
}
}