This is my code, I want the class to play through the wasted sound once, and then once it has finished playing play the gameOverBGM sound in a loop. However, the if statements condition is never met and the gameOverBGM line is never reached. I can't just input wasted.stop() after wasted.play otherwise the sound will not play through once and it will immediately play my gameOverBGM. need some advice, thanks.
public class GameOverWorld extends World { static GreenfootSound wasted = new GreenfootSound("Wasted.mp3"); static GreenfootSound gameOverBGM = new GreenfootSound("EndGameMusic.mp3"); public GameOverWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(1200, 675, 1); prepare(); wasted.play(); if(!wasted.isPlaying()){ gameOverBGM.playLoop(); } } void prepare(){ addObject(new BackToMenu(), 315, 450); addObject(new MenuIndicator(), 250, 200); } public void act(){ if (getObjects(GameOver.class).isEmpty()) showGameOver(); return; } private void showGameOver() { addObject(new GameOver(), getWidth() / 2, getHeight() / 2); } public static GreenfootSound getMusic(){ return gameOverBGM; } }