hello,
i start a music in my first world, but then i change world a few times. after i arrive a certain world i want the music to stop, i want to change it
how do i do that ?
sorry if my english is bad, its not my first language lol


1 | public static GreenfootSound bgSound; |
1 2 | bgSound = new GreenfootSound( "intro.mp3" ); bgSound.play(); |
1 | MyWorld.bgSound.stop(); |
1 2 | MyWorld.bgSound = new GreenfootSound( "replacement.mp3" ); MyWorld.bgSound.play(); |
1 2 3 4 5 6 7 | public static void setBackgroundSound(String name) { if (bgSound != null ) bgSound.stop(); bgSound = null ; if (name == null ) return ; bgSound = new GreenfootSound(name); bgSound.play(); } |
1 | setBackgroundSound( "intro.mp3" ); |
1 | MyWorld.setBackgroundSound("replacement.mp3); |
1 | myWorld.setBackgroundSound( null ); |