Help with Button-What did I do wrong?

This is what I have set up for my sound effects button (it's not working):

When touch is pressed and attribute self.soundon=true:
change attribute self.soundon to false, and change image.

When touch is pressed and attribute self.soundon=false:
change attribute self.soundon to true, and change image.

When attrebute self.soundon=true:
change attrebute game.audio.sound to 1

When attrebute self.soundon=false:
change attrebute game.audio.sound to 0

The image isn't changing, and neither is the attribute! What did I do wrong?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2012

    Hi @ds1239 it's best to have this toggle with a Rule and its Otherwise section:

    Rule: When touched is pressed
    Rule: ---nested in the above--- When self.soundon is true
    Change Attribute self.soundon to false
    Change Image
    Otherwise
    Change Attribute self.soundon to true
    Change Image

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ds1239ds1239 Member Posts: 33
    That works, but the button is in my pause menu. Once i go back to the level, then back to pause, it turns the sound on even though i pressed off the last time i was in pause
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Oh, I see, I thought it was for the user to toggle sound on and off...

    So in this case, just put Change Attribute self.soundon to true in an actor at the outside of your scenes play area; and in your pause button, just a Change Attribute self.soundon to false. I think that should work for you.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ds1239ds1239 Member Posts: 33
    It is to toggle sound, in the pause menu.
  • ds1239ds1239 Member Posts: 33
    It works when I go to any other scene, but when I go to pause it resets the Sound Audio attribute to 1 even though I turned it to 0 before.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    OK, if it's to toggle the sound, then you don't need a custom attribute, you can just toggle the sound volume....

    But to check first, with your pause game, I assume you've got a button on each scene with a Pause Game behaviour in it's Rules?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ds1239ds1239 Member Posts: 33
    Ok. That worked. Thanks for the help!
Sign In or Register to comment.