like as in coding a function?


1 2 3 4 | public void stopped() { // code to pause (or stop) the music here } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import greenfoot.*; // class declaration statement public class myWorld extends World // *** end class header *** // *** begin class code *** { // field declaration statement(s) GreenfootSound backgroundMusic = new GreenfootSound( "circles.mp3" ); // *** begin instance object constructor(s) *** public myWorld() { super ( 600 , 400 , 1 ); backgroundMusic.playLoop(); // etc. prepare(); } |
1 2 3 4 | public void stop() { backgroundMusic.stopLoop(); } |