Im making a game and in the main menu I put a music using another world to initializated that, but I dont know how to turn off the music when I click in start game on main menu.
My code:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class musica here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class musica extends World
{
//GreenfootSound backgroundMusic = new GreenfootSound("Metallica - Battery (8-Bit).mp3");
/**
* Constructor for objects of class musica.
*
*/
public musica()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1000, 480, 1);
}
public void act()
{
Greenfoot.setWorld(new menu());
//if (backgroundMusic.isPlaying()){
// backgroundMusic.stop();
//Greenfoot.setWorld(new Level1());
//}
//backgroundMusic.playLoop();
}
private GreenfootSound music = new GreenfootSound("Metallica - Battery (8-Bit).mp3");
public void started()
{
music.playLoop();
}
public void stopped()
{
music.stop();
}

