[SOLVED] Sound effect loops and plays one over another multiple times before exiting layout. (?!)

0 favourites
  • 5 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hello, Im relatively new to programming in general and making some n00b mistakes here. So any help would be much appreciated.

      1. Player is generated within the screen layout.
      2. Every tick, the player loses some health.
      3. After x ticks, players health reaches 0.
      4. Once players health is 0 or less than 0,
      5. #5 kicks in
      6. System sets for the Global Boolean PlayerIsAlive = False.
      7. then it jumps to #7 where if the Global Boolean PlayerIsAlive = False - run the following commands
      8. Set Player to death animation
      9. on the HUD - display player state
      10. Stop all Audio
      11. Start Sound "efxDeath" - player only once
      12. Deactivate two groups in the PlayerControllEvents so the user cannot control player.'PlayerControllEvents' Events sheet - contains all the animation tied to the player and player control
      13. System waits for 2 seconds, so it has enough time to play the Sound 'efxDeath'
      14. System then restarts layout

    Results: Sound 'efxDeath' plays multiple times for 2 seconds. From the debug preview - it looks like the game checks steps 5 and 7 multiple times - causing the audio sound to multi-loop

    Expected: Sound 'efxDeath' should play only once.

    Subscribe to Construct videos now
  • A little confused at some of the code, but a simple fix would be add a boolean check for the "PlayerIsAlive" under the "Else". And move all of those actions from under the current PlayerIsAlive false condition, to under the "Else", so it only triggers once.


    PlayerIsAlive = True - Set PlayerIsAlive to False

    stop "music"

    etc, etc

  • Thanks for the speedy reply FromChris!Your logic made a lot of sense. I have updated the Events Sheet and still get the same error. The error appears when the player's health drops to 0 or if the player exits the Screen Layout.


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think you forgot the most important part! The boolean check "PlayerIsAlive" with the else!

  • FromChris! Thank you so much for figuring this out! Oh man - I had no clue I could add another condition to the Else statement. Facepalm

    Appreciate all your help, Cheers!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)