I have been trying to stop my background music when my game ends. It starts playing when you compile and run the program but it keeps playing after the game ends and the gameover sound plays. This is what I have in one of my actor classes right now because I couldn't figure it out in the world class either:
GreenfootSound sound = new GreenfootSound("GameOfThrones.mp3");
public void endGame()
{
if (crabEaten == 1)
{
sound.stop();
Greenfoot.playSound("gameover.mp3");
Greenfoot.stop();
}
}


Now, in the code you posted you are creating a