So i am programming a screen in which there are three options to select. as you mouse of the options, a sound is played. the issue is that as it is constantly checking if my mouse is there, it is constantly playing the sound while the mouse is there as opposed to only playing it once.
public class TripleRsmall extends TripleR
{
private boolean onThis=false;
public void act()
{
if(Greenfoot.mouseMoved(null)){
onThis = Greenfoot.mouseMoved(this);
}
if(onThis){
setImage("Street-TripleR_BIG.png");
Greenfoot.playSound("MotorcycleStart.mp3");
}
else{
setImage("Street-TripleR_SMALL.png");
}
}
}

