Can I use variables on a global sprite to disable sound (music)?

0 favourites
  • 3 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi

    I've been working on the sound part of my game, and thus I've created an options button (only accessible in the main menu) to "toggle on and off" only the sounds that you would call music in the game. I thought it would be possible to go about this by creating a sprite on a global layer that every layout shares. This sprite (GlobalValues) has an instance variable assigned to it simply called music with a value of either 1 or 0. Pressing the button changes the value between 1 and 0.

    Every layout (playable level) has trigger as follows:


    + System: On start of layout

    ----+ GlobalValues: Music = 0

    -----> (no actions)

    ----+ GlobalValues: Music = 1

    --------+ Audio: [X] Tag "Music" is playing

    ---------> System: Wait 1.0 seconds

    ---------> Audio: Play Stage.webm looping at volume -10 dB (tag "Music")


    Apparentely this doesn't seem to work as expected on the start of layout with the GlobalValues variable music assigned with 0. Is it possible to create conditions based on global sprite variables (in this case on the start of layout) or am I just missing something in my framing of conditions?

    If I seem to complicate the whole concept of disabling music, do tell me if there's a better way to go about it.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello, Razertune!

    Why are you using a sprite with an instance variable instead of just using a global boolean variable?

    You could have a musicOn global variable. And check if it's "true" or "false" whenever you have to check it like you're already doing.

    Hope this helps. Cheers.

  • It worked terrific! Thank you!

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