How do I mute/unmute from different layouts?

0 favourites
  • 4 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • 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

  • Try Construct 3

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

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

  • 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?

  • 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.

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