I'm currently working on a dodgeball game. As usual, all players should be out for the game to be over. In the program of the Ball, it says there the following:
public void act(){
move (2);
if(isTouching(Player1.class))
{
getWorld().removeObject(this);
}
if(isTouching(Player2.class))
{
getWorld().removeObject(this);
}
if(Player1.class == null && Player2.class == null)
{
Greenfoot.setWorld(new Gameover());
}
}
However, if a player got hit, it errors into "Actor not in world."
What can I do to fix this? And how can I make a program wherein the two players should be hit first then go to the Gameover screen?
