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

2016/3/6

background music in my project is playing before i run it

fearDnine fearDnine

2016/3/6

#
my sound is still playing when i switching world and before i run the game
Super_Hippo Super_Hippo

2016/3/6

#
Instead of placing the 'playLoop' code into the constructor of your world (I guess you do so, you didn't provide any code), use these methods in your world class:
private GreenfootSound bgMusic = new GreenfootSound("nameOfTheFile.something");

public void started()
{
    bgMusic.playLoop();
}

public void stopped()
{
    bgMusic.pause();
}

public void nextLevel()
{
    bgMusic.stop();
    Greenfoot.setWorld(new NameOfTheOtherWorld());
}
You need to login to post a reply.