This site requires JavaScript, please enable it in your browser!
Greenfoot back
MikeItOrNot69
MikeItOrNot69 wrote ...

2013/12/18

Background Music Stop

MikeItOrNot69 MikeItOrNot69

2013/12/18

#
Can someone help me with my program. I have a project due and i'm stuck trying to get rid of the background music when I die. When I die I play another sound so I want to hear just that instead of both the background music and the game over music
danpost danpost

2013/12/18

#
To be able to control the music (sound), you need to create a reference to the sound that is to play by creating a GreenfootSound object:
private GreenfootSound bgSound = new GreenfootSound("/* sound filename */");
Then your world constructor can start it with:
bgSound.play(); // or 'bgSound.playLoop();'
And later you can stop it with:
bgSound.stop(); // or 'bgSound.pause();
If you need access to the sound object from another class, you will need a public 'get' method to return the value of 'bgSound' from the world.
You need to login to post a reply.