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

2013/5/22

Music

ursulaboy ursulaboy

2013/5/22

#
How do I make music play when the game is started and stop when it has ended?
Gevater_Tod4711 Gevater_Tod4711

2013/5/22

#
First you need a GreenfootSound object in your world class.
private GreenfootSound sound = new GreenfootSound("soundName.mp3");
Then if Greenfoot starts you start the sound and if it stops you stop the sound using the methods started and stopped:
//again in your world class:
public void started() {
    sound.play();
}

public void stopped() {
    sound.stop();
}
danpost danpost

2013/5/22

#
To be able to stop any music that is playing, you need to create a GreenfootSound object and use GreenfootSound class methods on that object. Refer to the GreenfootSound class documentation in the Greenfoot API.
You need to login to post a reply.