Sound not responding

Here’s another student project that isn’t working as intended. In this case, once the baseball reaches a certain size you should hear the sound of a bat hitting the ball. An earlier version had the sound playing but it kept playing over and over. This version doesn’t play at all.


Did the student use watchers to see what the scale is equal too? The conditional of baseball.scale == 1.51 is tricky because it might be 1.5100 which isn’t exactly equal to 1.51. I didn’t have the bat hitting baseball sound on my laptop (which might be the problem with yours, I don’t know where that file is located) but I swapped the bat sound for another sound and it worked when I said baseball.scale > 1.51 BUT would continue playing so I can add an additional (&&) condition to say if (baseball.scale < 1.61) (which is the next click value) OR you could have a variable inside of the sound conditional that increases by one after played and then would cancel out a condition to play the sound (ie. if (baseball.scale > 1.51 && baseballSound == 0) { playSound... ; baseballSound = baseballSound + 1; })

Hope that makes sense! Basically you are trying to make sure the conditional is true and then make it not true, or else it will keep playing.


Thanks Brad, That’s very helpful.