[Pause menu] How to keep in memory the state of a button

jol

  • *
  • Posts: 174
Hello,

Let's say I have a toggle music button in my pause menu, how can I do to keep in memory his state when the pause menu is closed ?

xTage

  • Posts: 47
create a game attribute, of boolean type, and when the player toggle the sound button, change de value of this attribute.
when you want to check, just call this attribute. the save/load game keep all global attributes values.

jol

  • *
  • Posts: 174
It is what I do, but the attribute is in the actor, so I think it is reset every time the pause menu close, and the actor is killed.

letmethink

  • *
  • Posts: 2545
Use a game attribute then.
~Letmethink

xTage

  • Posts: 47
game attribute is global, i think you are using the normal attribute. global is purple.

when create a global attribute, you can use it in all behaviors/actors/scene etc.

jol

  • *
  • Posts: 174
Hello,

this is my code :


However if I close my pause menu, with the music button turned off and re open it, the state button of my music is on again (the button animation, the volume stay to 0)

sdieters

  • Posts: 2068
I think the "stop" block is t working correctly. I woukd start by replacing the number GA by a boolean GA and instead of using 2 if statements, us an if statement and an otherwise if statement. First start with an if statement which checks if the mouse is released on self. Inside that wrapper add an if statement which checks if musicOn (the boolean GA) is true. If it is treu set it to false, mute music, and switch animation to 0. Then beneath the if statement, add an otherwise if statement. This will run if the previous statement (if musicOn in this case)returned false. Here you add the rest of the code.

Good luck!
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p

sdieters

  • Posts: 2068
Oh, im sure this isnt the problem (or it has never been my problem) but only change the value of yohr GA AFTER you changed the rest.
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p