I'm stuck with the following problem:
I have a MainmenuWorld, where I start playing a sound named "song" in a loop.
I made two constructors for the MainmenuWorld, only one plays the song (the one with no variables passed) because when I set another world and then come back to the Mainmenu, the song is played again and so its played double times at once.
My problem is:
I want to be able to turn the song on and off again and I want to do it with setting its volume to 0 / 100. I just tried it with:
It works but when I go to another world and come back to the Mainmenu again it doesn't. How can I solve that?
1 2 | GreenfootSound song = new GreenfootSound ( "song.mp3" ); song.playLoop(); |
1 2 | if ( Greenfoot.isKeyDown ( "g" ) ) song.setVolume ( 0 ); if ( Greenfoot.isKeyDown ( "f" ) ) song.setVolume ( 100 ); |