Playing a sound, when you reach a certain score... (sound not playing)

sebstarr

  • *
  • Posts: 259
Hey. I'm looking to complete this game I've been working on.

It's a time-based game and the idea is, when you reach 20 points - it will play a sound.

Then, when you reach 40 points - it will play another sound.

At the moment I've tried;

always;
if score = 20
play sound on channel 5
if score=40
play sound on channel 6

Those didn't work. So I tried

When created
do every 1 second
If score = 20
play sound on channel 5
if score = 40
play sound on channel 6

That doesn't work, either. Not entirely sure what else I can try.  ::)

Seb.

twotimingpete

  • *
  • Posts: 1667
Post a picture of your behavior. Also try testing with print statements just to see if the logic works.

BTW, if you say "if score = 20 play sound" it'll play the sound many times per second if the score is 20, so that's generally not a good idea unless the score is instantly changed away from 20 the first time the sound plays.

dtrungle

  • Posts: 1938
Like pete said, you'll need a boolean flag to set the sound to trigger once.

As for the sound playing, I think it is because your condition is detecting for only when score = 20. If score moves from 19 to 21, the sound will not play.