Hello, I am trying to make a game over screen appear when the player dies. The code compiles and runs however, the .setBackground() method isn't actually changing the background. The removeObjects method isn't working either. Here's the code I have written:
public void act()
{
int xpos = getX() - 5;
if (xpos <= 0)
{
getWorld().removeObject(this);
}
else
{
setLocation(xpos, getY());
Actor player = getOneObjectAtOffset(0,0,RocketPlayer.class);
if (player != null)
{
getWorld().removeObjects(getWorld().getObjects(Actor.class));
getWorld().setBackground(new GreenfootImage("gameOver.jpg"));
slow();
Greenfoot.setWorld(new MainMenu());
}
}
}
