How do I stop playing sound effect after button is tapped

0 favourites
  • 3 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • I have 4 buttons on the main menu. When a button is tapped a sound plays, a black background fades in and you are taken to the corresponding layout.

    The problem is, during the fade in of the black background you can click on any of the buttons and the sound can still play.

    I've been looking for the longest time for a solution on how to stop the sound from playing when any button is tapped. I've tried things like:

    Add an Audio is tag playing condition to the button clicked event and invert it..

    ...make a global variable that tracks if the button was clicked, where on its first click, it'll set it to 1 and allow a song to play, but if you click again, it is set to 2 and won't play.

    "On button clicked -> Sys: Add 1 to variable -> | if variable = 1 -> play sound"

    Take your button sprite and create boolean variable. Name it something like "Is_Playing". Now events:

    Main Event

    On BUTTON clicked

    Sub-Events

    • Is_Playing : Stop, toggle boolean "Is_Playing"
    • Else : Play, toggle boolean "Is_Playing"

    I guess i'm just not C2 savy enough to understand why any of these just won't work.

    [/img]

    If anyone can help explain things, i'd be very grateful.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can put your On touched events in a Group (like Menu Buttons) and Deactivate the group when any button is pressed. This will block any more button events until you Activate the group again.

  • Oh you are so awesome!

    That was too easy. Learn something new everyday.

    Thank you again.

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