I also got an Actor named SoundManager
A subclass named StartSound
and a class named StopSound
I have 3 worlds:
- Startmap -- StartSound added as object
- Infomap -- StopSound added as object
- Level1 -- StopSound added as object
When I press run, the sound startscreen.wav gets played in Startmap, but as soon as I click the button to go to a new world (Infomap or Level1) it won't stop the sound.
public class SoundManager extends Actor
{
public GreenfootSound startscreen = new GreenfootSound("startscreen.wav");
public void act()
{
// Add your action code here.
}
}public class StartSound extends SoundManager
{
public void act()
{
startscreen.play();
}
}public class StopSound extends SoundManager
{
public void act()
{
startscreen.stop();
}
}private void checkClick()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
if(mouse != null)
{
if (Greenfoot.mouseClicked(this) != false)
{
if (mouse.getButton() == 1)
{
worldnamehere worldnamehere = new worldnamehere();
Greenfoot.setWorld(worldnamehere);
}
}
}
}
