Play sound once on button clicks

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • I've created a button that plays a sound when clicked, and it works fine but i wanted it so that the sound will only play once, even if the button has been clicked several times during the sound playing and the only when the current sound has finished can the sound play again.

    I've seen a few threads on here regarding audio playing once, and they've all been fixed by using the 'trigger once' condition, but this hasn't worked for me.

    Right now, if i continiously press the sound button, the sound will constantly play, which i understand it will do normally. I added a 'trigger once' condition hoping this would fix the issue, but it hasn't worked.

    I'm sure i'm missing something obvious but would appriciate help on this.

    dropbox.com/s/3hc55wysgapc0gr/example.capx

    Thanks

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

  • Or you could 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.

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Or you could 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.

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

    That would make it nescessary to add a second event to set the variable back on sound end, because he wants the sound to be playable again when ended..

    Just using one condition and not adding a variable seems a lot easier..

  • LittleStain Thank you, your solution worked. Seems so simple

    TechnoBeaver Thanks for replying, appriciate it.

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