I am trying to end the music on my start screen as soon as I switch worlds in my game. Normally, the music finishes an entire loop before stopping. I have an actor on my startscreen that when pressed, it will switch worlds to the game screen but I don't know how to stop the music right away.
public class StartScreen extends World { /** * Constructor for objects of class StartScreen. * */ public StartScreen() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); prepare(); Greenfoot.playSound("Opening.wav"); }
public class PlayButton extends Actor { /** * Act - do whatever the PlayButton wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if(Greenfoot.mouseClicked(this)) { Greenfoot.setWorld(new GameScreen()); } } }