Hello I'm new at green foot and need some help I want to code it so that a sound is play every other click. How would I do that?
here is what I have so far. I think you should set a variable to hold a count so when the sound play time will be 1. I'm just kind of confuse.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public void sound() { MouseInfo mouse = Greenfoot.getMouseInfo(); GreenfootSound gfs1 = new GreenfootSound("Beep.wav"); int time = 0; if (Greenfoot.mouseClicked(this)) { if (mouse.getButton() == 1) // Left mouse pressed? { gfs1.play(); time = time + 1; } } } |