I want that every time when the run button is pressed that the music starts and every time when the run botton its paused that the music stop.
PLEASE HELP!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.lang.Object; import java.util.List; /** * Write a description of class Schlachtfeld here. * * @author (your name) * @version (a version number or a date) */ public class Schlachtfeld extends World { static GreenfootSound backGroundMusic = new GreenfootSound("MarioThemeAcapella.mp3"); public static void startMusic() { if(!backGroundMusic.isPlaying()) { backGroundMusic.play(); } } public static void stopMusic() { backGroundMusic.stop(); } public void act() { startMusic(); if (Greenfoot.isKeyDown("e")) for (Object obj : getObjects(Bomb.class)) ((Bomb) obj).explode(); if (Greenfoot.isKeyDown("m")) for (Object obj : getObjects(Bomb2.class)) ((Bomb2) obj).explode2(); if (getObjects(Bomber1.class).isEmpty() && !getObjects(Bomber2.class).isEmpty()) { winnerLuigi(); stopMusic(); } if (!getObjects(Bomber1.class).isEmpty() && getObjects(Bomber2.class).isEmpty()) { winnerMario(); stopMusic(); } } public void winnerMario() { List objekte = getObjects(null); removeObjects(objekte); setBackground("winnerMario.jpg"); } public void winnerLuigi() { List objekte = getObjects(null); removeObjects(objekte); setBackground("winnerLuigi.jpg"); } /** * Constructor for objects of class Schlachtfeld. * */ public Schlachtfeld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(15, 9, 60); prepare(); } it doesnt work i want that it stops when someone wins ????