Stop playing sound before going on to next function

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.

127 thoughts on “Stop playing sound before going on to next function”

  1. hello!,I love your writing so much! percentage we communicate extra about your post on AOL? I need an expert in this space to unravel my problem. May be that’s you! Taking a look ahead to peer you.

    Reply
  2. I simply could not go away your web site before suggesting that I extremely enjoyed the usual information an individual supply to your visitors? Is gonna be back regularly in order to check up on new posts.

    Reply
  3. I just couldn’t leave your web site before suggesting that I actually loved the usual info an individual supply in your visitors? Is gonna be again regularly in order to check out new posts.

    Reply
  4. You actually make it appear so easy along with your presentation however I to find this topic to be really something which I believe I’d by no means understand. It kind of feels too complex and very extensive for me. I am looking ahead on your next put up, I’ll try to get the hold of it!

    Reply
  5. Yesterday, while I was at work, my sister stole my iPad and tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is totally off topic but I had to share it with someone!

    Reply

Leave a Comment