import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Music1 here. * * @author (your name) * @version (a version number or a date) */ public class Music1 extends Actor { GreenfootSound myHomesound = new GreenfootSound("menu.mp3"); boolean firstTurn = true; /** * Act - do whatever the Music1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if(firstTurn) { myHomesound.play(); firstTurn = false; } if(Greenfoot.mouseClicked(this)) { if(myHomesound.isPlaying()) { myHomesound.pause(); setImage("mute.png"); }else { myHomesound.play(); setImage("sound_logo.png"); } } if (Greenfoot.mouseClicked(Play.class)) { Greenfoot.delay(1); myHomesound.pause(); Greenfoot.setWorld(new MyWorld()); getWorld().removeObject(this); } } }