Audio Control

Get help using Construct 2

Post » Mon Aug 12, 2013 4:59 pm

I have a button that's a picture of a speaker named "Sound". When someone clicks it, it will turn to the animation version of the speaker with a red circle and line through it over it and all game sounds should become muted.

If someone clicks it again, the speaker image should return to normal and the sounds of the game should become audible again but somehow my code is not working.

Button animations are:

Default:
Off:

and the code is currently:



Can anyone tell me why this isn't working or provide links to a helpful tutorial on the subject?

Thanks!!
B
18
S
2
Posts: 61
Reputation: 902

Post » Mon Aug 12, 2013 5:12 pm

Both events are triggering in the same tick, so they're cancelling each other out. It's a long way round, but I'd suggest the following method:

Give your sound object an instance boolen "OnOff" or whatever.

Use a single On touched event that toggles the boolean state.

Then create two more events, one that tests if "OnOff" is true, the other tests if its not (inverted condition). Set your audio silence and animation states accordingly.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Mon Aug 12, 2013 6:12 pm

Yes that did the trick. I assigned boolean value "OnOff" to my sound button and then coded it in as you said. Here is the code if anyone wants to see:



Thanks @GeometriX
B
18
S
2
Posts: 61
Reputation: 902


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests