I got this class
but when you play the game i would like to stop the sound that actually plays. how can i access to the currently playing sound?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class son here. * * @author (your name) * @version (a version number or a date) */ public class son extends menu { private GreenfootImage sonOn; private GreenfootImage sonOff; private boolean Off = true; public GreenfootSound sound = new GreenfootSound("cliff.mp3"); public son() { sonOn = new GreenfootImage("son1.png"); sonOff = new GreenfootImage("son2.png"); } public void act() { if ( Greenfoot.mouseClicked(this) && Off) { setImage(sonOn); Greenfoot.delay(50); sound.playLoop(); Off = false; } else if ( Greenfoot.mouseClicked(this) && !Off) { setImage(sonOff); sound.pause(); Off = true; } } }