Good evening guys,
My game crashes when im trying to remove an object from another class that extend Actor.
I tried different syntaxes for removing the Object but everytime I got a NullPointerExeption.
The methods function is to remove the Startscreen, Desciption and Buttons after the user selects a gamode through the buttons and presses enter.
public void act()
{
if (getWorld() != null) {
if (Greenfoot.isKeyDown("enter")&& Welt.i==0 && Welt.gamemode!=0) {
getWorld().removeObject(this);
//World W = getWorld();
//W.removeObjects(W.getObjects(Description.class));
//W.removeObjects(W.getObjects(Button.class));
//Button buttons = (Button)getWorld().getObjects(Button.class);
//getWorld().removeObject(buttons);
//Description description = (Description)getWorld().getObjects(Description.class);
//getWorld().removeObjects(description);
//getWorld().removeObject(getWorld().getObjects(Button.class));
//getWorld().removeObjects(getWorld().getObjects(Description.class));
Welt.i = Welt.i+1 ;
}
}
}
