Audio on/off

0 favourites
  • 6 posts
From the Asset Store
100+ Musical High Quality Sound Effects for your game!
  • Hey all,

    I've got problem with audio.

    There is my .capx file:

    ge.tt/9nP5VAw/v/0

    I want to have on/off button to music. When player click music button, background music is off, and on that button will show mute icon, when he click again on that button, he got back music and mute icon is destroyed.

    I don't know how to fix that ;/

  • s000.tinyupload.com/index.php

    Main problem was onoff=1 condition always triggering, because you set it to 1 in the subevent before this, in case it wasn't already 1. Use else instead.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your help.

    I should do any global variable if I want have audio control in settings panel of game?

  • Haven't worked with audio yet (I'm rather new to the program myself), but:

    with audio there comes a condition: is silent. And you can set the game to silent. So there is not really a need for a "muted"-variable.

    Other than that, if you want your player to adjust volume levels for music, speech, sound effects differently, I guess you need 3 global variables, each standing for the volume decrease for bgm, speech, sfx. And for each tick, set the volume for the tag bgm to x, speech to y and sfx to z.

  • I usually set a global variable so that when they return to the page, it remember's that they turned off the music.

    I make a sprite button with two frames, 0=on & 1=off

    the global variable hold the same values so the frame can be set with it when returning to the page.

    I check the sprite for a touch and if the sprite is on frame 0 switch it to 1 and if it's a 1 switch it to 0. and set the global.

    The common problem with buttons:

    since the second event also sees the click, and the frame switched in the first event to 1, it will fire switching it right back to 0.

    So, when the first event fires, wait 0 or .1 before setting the value, so that it will wait a tick before setting the value. The second event saw the value was still 0 and didn't fire. Then the value changes next tick.

    (wait 0 waits until the next tick.)

  • Paradox thanks for that advice, but I have still problem, when I go to other layout music is playing (when is on) but when I come back to start layout music start playing from begining.

    You can check this there:   http://ge.tt/6GiQqDw/v/0

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