How do I make a toggle Mute button?

0 favourites
  • 3 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • Hello!

    In the Pause Menu I made for my game, I want the "Mute" button to toggle the sound on and off with each press.

    (As a system, all the buttons in the Pause Menu are grouped into a family, and each has its own instance variable. Navigation goes from top to bottom.)

    I tried using a local boolean for the toggle function, but I couldn’t get it to work correctly. It mutes the sound on the first press, but pressing it again doesn’t unmute.

    I’d really appreciate your help.

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Better with a global variable. The local won't retain it's value so it's going to revert to false.

  • Better with a global variable. The local won't retain it's value so it's going to revert to false.

    I didn't know that, thank you so much <3 It's working perfectly now!

    Edit: When I used a global variable, it worked, but in cases where 'Reset global variables to default' occurs — like when the player dies or the level changes — it was being reset. Then I noticed the 'static' option, and after researching it, I found out that it allows a local variable to behave like a global one by remaining persistent. I updated it accordingly, and now it works exactly as I wanted. Thanks again!

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