How do I mute/unmute from different layouts?

Get help using Construct 2

Post » Wed May 20, 2015 1:42 am

So I have a mute toggle button that toggles all music and sounds on/off. I am currently using the set toggle silent function. The problem is when I mute all sounds from one layout, and I unmute(toggle) all sounds on another layout, the music that usually starts on the start of layout doesn't start playing. I can see the logic behind this, but I can't seem to figure out how to get this the way I want it to be. Any suggestions or help would be much appreciated!

Thank you
B
3
Posts: 2
Reputation: 179

Post » Wed May 20, 2015 1:46 am

just make a Global Variable that has the state of the music..then add an Action to OnStartOfLayout that always sets the audio to whatever the state is..
B
97
S
32
G
16
Posts: 1,200
Reputation: 16,682

Post » Wed May 20, 2015 11:21 pm

How exactly would the Global Variable correspond with the toggle of the mute button? I don't quite get how to toggle sound other than using the Set silent function.

Edit:

The thing is within my game global variables are often being reset between layouts, so I don't think using global variables would be optimal for this game. It's just a tiny bug that occurs in the game.

Edit 2:
I found out that you can toggle using boolean instance variables, but by using instance variables I guess each separate layout won't be able to grab the instance variable value from another layout?
B
3
Posts: 2
Reputation: 179

Post » Thu May 21, 2015 4:52 am

Instance variables will only be global if you make the object global. Otherwise they will not retain their value between layouts.

You don't need a built in toggle.. just do this:

TO MAKE THE OPPOSITE HAPPEN:
If isMusicOn = "yes" then Set isMusicOn to "no"
else
Set isMusicOn to "yes"

Make sure you are untoggling Silent before you start playing the music.
B
97
S
32
G
16
Posts: 1,200
Reputation: 16,682


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests