Sound switch on / off.

Hi!

I've got a problem with my game - so, I've got a settings menu with slider, so you can adjust the sound volume in the game.

I've got also the sound on / off in the pause menu and I want the player to could easily mute the sound in the game and if he want to bring it back it will come back to the settings value and here is what I do:

If touch is released and music volume > 0

Change att music.volume (the one I've made for the slider purposes, it is connected to game.audio.music.volume in the devices section) to self.savemusic (real attribute in the actor).

If touch is released and music volume = 0
change att. self.savemusic to att music.volume

It does not work, it is muted all the time.

Any ideas how to change it?

Comments

  • BoomshackBarryBoomshackBarry Member Posts: 712
    I think what you've got there is an endless loop. Say you start with volume=0, then you press the button, so volume now = 1 (for example). But as you're still touching the button (even for fractions of a second) then the rule is now firing again and registering that touch is pressed and volume=1, so it mutes again, and so on...

    This post about a similar issue might help:

    http://forums.gamesalad.com/discussion/56573/making-a-boolean-switch
  • UtopianGamesUtopianGames Member Posts: 5,692
    edited May 2013
    In your Music on off button you could use a game integer call it "Music" leave it set to 0.

    When touch is pressed change game.Music to (game.Music+1)%2....every time you touch it will change it from 0-1-0-1-0

    When its 0 set the volume to your slider when its 1 mute the sound.

    It might be best when the player touches the slider (they obviously want to change the volume) to change it back to 0.

    Darren.
  • cucurbitcucurbit Member Posts: 68
    It works!

    Thank you so much!
  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2013
    In your Music on off button you could use a game integer call it "Music" leave it set to 0.

    When touch is pressed change game.Music to (game.Music+1)%2....every time you touch it will change it from 0-1-0-1-0

    When its 0 set the volume to your slider when its 1 mute the sound.

    It might be best when the player touches the slider (they obviously want to change the volume) to change it back to 0.

    Darren.
    @DeepBlueApps.com

    Or you could avoid the modulus and use:

    1-Game.Music
Sign In or Register to comment.