1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import greenfoot.*; /** * This class defines a crab. Crabs live on the beach. */ public class Crab extends Actor { public void act() { move( 4 ); if (isAtEdge()) { turn(- 3 ); GreenfootSound sound = new GreenfootSound( "applause_y.wav" ); sound.play(); sound.stop(); } } } |
Each time I run the posted code the sound file (applause) keeps running. How can I change the code so it only plays once. Thank you for your help.