I've encountered an issue for when I try to call a sound a play when I shoot a dart. My actor has an if statement to see if the space key is down, and if a counter is above a number. If both are true, the dart spawns and the sound plays, but the problem is that the sound only plays for the first dart and then randomly after that. I've had a similar sound function for when the actor gets hit, and the sound plays even if the there's another hit immediately after so I don't think it has anything to do with the length of the sound.
Thanks in advance
1 2 3 4 5 6 7 8 9 10 11 | public void pewSound() { pew.play(); } if (Greenfoot.isKeyDown( "space" ) && DartLimiter > 8 && power== 0 ){ DartLimiter = 0 ; //dart spam reset pewSound(); DartThrow fire = new DartThrow(); //the actual shooting getWorld().addObject(fire, getX() + 3 , getY() + 1 ); //adds the dart } |