I was tasked to create a simple mini game based solely on Javascript. I encountered a problem as I was adding in sound effects..
After the player drowns, the game should 'return' to its initial frame with one 'live' count decreased. During the drowning action, it plummets down the lake while the sound effect comes into place. However, the sound is activated a few .seconds late and the player freezes at the bottom of the lake. The game does not return either.
I have also tried adding stop() but it doesn't work. Here's a fragment of the relevant code.
gameCharacter_y +=2;
drownSound.play();
return;
Been stuck for days now and am an absolute beginner, would appreciate and be grateful for any suggestions!
Thanks.
question from:
https://stackoverflow.com/questions/65948237/stop-playing-sound-before-going-on-to-next-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…