I have sounds that play with acts but how do i add background music?


import greenfoot.*; public class MyWorld extends World { GreenfootSound backgroundMusic = new GreenfootSound("musicFilename.mp3"); public MyWorld() { super(600, 400, 1); backgroundMusic.playLoop(); // etc. } // etc. }
// *** begin class header *** // import statement(s) import greenfoot.*; // class declaration statement public class MyWorld extends World // *** end class header *** // *** begin class code *** { // field declaration statement(s) GreenfootSound backgroundMusic = new GreenfootSound("musicFilename.mp3"); // *** begin instance object constructor(s) *** public MyWorld() { super(600, 400, 1); backgroundMusic.playLoop(); // etc. } // *** end instance object constructor(s) *** // *** begin method(s), if any *** // etc. // *** end method(s), if any *** } // *** end class code ***
public void stopped() { bg.setVolume(0); //change bg to what you declared the file as } public void started() { bg.setVolume(100); //change bg to what you declared the file as }
public void stopped() { bg.pause(); } public void started() { bg.playLoop(); }