How can I change my background music when I change from world to another? What would the code be?
private GreenfootSound song;
...
public /*World name*/(GreenfootSound s //...)
{
...
song = s;
song.play(); //or song.playLoop() if you want to go on continously
}
public void teleport()
{
song.stop();
//everything from your last question
}public GreenfootSound getSound()
{
return mySound; //Or whatever you called it
}public void teleport()
{
getWorld().getSound().stop();
...
}public GreenfootSound getSound()
{
return mySound; //Or whatever you called it
}public void teleport()
{
getWorld().getSound().stop();
...
}//Change getWorld().getSound().stop(); //to ((GreenfootWorld)getWorld()).getSound().stop();
public void act()
{
if (!songName.isPlaying())
songName.play();
...
}