GameSalad

Changing Boolean with change attribute?

igpxnaruto4igpxnaruto4 Posts: 81
edited July 2012 in Working with GS (Mac)
How do i change a Boolean with change attribute?

Comments

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,786
    Just do this:

    Change attribute:
    game.yourattriubute to true.
    Or, if you wanted to change it to false do this:
    game.yourattriubute to false.

    Hope this helps
  • AsymptoteellAsymptoteell Posts: 1,362
    You can't change an actor's "visible" attribute, though, so if you're running into trouble trying to do that, instead change attribute self.color.alpha to zero or one.

    Asymptoteell
  • That's what i tried but it didn't work... lets try it again...
  • GlomGlom Posts: 59
    Make sure you click the 'e' before you input the true or false or other value. I've had trouble with attributes not changing when I just click the textbox and enter the value without clicking the 'e' first.
  • what im trying to do is a make a sound on and off button, what happens is when touch is pressed and sound is true it changes the image, pauses the sound and changes the Boolean to false(Boolean is set to true in the beginning) then i have another rule with the exact opposite. y isn't it working?
  • "Make sure you click the 'e' before you input the true or false or other value. I've had trouble with attributes not changing when I just click the textbox and enter the value without clicking the 'e' first."
    What E?
  • AsymptoteellAsymptoteell Posts: 1,362
    Next to the box where you can type, there's a lowercase e that brings up a window (the expression editor where you pick attributes.
  • Didn't change anything, the pic isn't changing...
  • If you want to make a toggle state button like a sound on off button do this.

    Make a interger attribute and call is soundOff have it set to 0

    Have a rule when touch is pressed:
    change attribute to (soundOff+1)%2

    then have a rule when attribute soundOff =1
    change attribute device sound volume to 0
    and change image to sound off button image
    then open up the otherwise section of that rule and inside there have this:
    change attribute device sound volume to 1
    change image to sound on button image

    cheers
  • well ya i know how to use integers, but i was just checking how to change booleans.
  • Yes but your saying you want to make a toggle sound button. You would want to use a interger for that so u can use the modulo function i put above so you dont have to have seperate rules and what not checking the conditions each time and all that. The expression i put above will toggle it back and forth for you

    cheers
  • Yeah I am having the same problem with booleans.
    I dont know how I would change this to true or false, I tried 1 for true and 0 for false. There is no true or false that I found in the "e".
    I thought these are the best attributes for on/off buttons.
  • ericzingelerericzingeler Posts: 334
    If you want to make a toggle state button like a sound on off button do this.

    Make a interger attribute and call is soundOff have it set to 0

    Have a rule when touch is pressed:
    change attribute to (soundOff+1)%2

    then have a rule when attribute soundOff =1
    change attribute device sound volume to 0
    and change image to sound off button image
    then open up the otherwise section of that rule and inside there have this:
    change attribute device sound volume to 1
    change image to sound on button image

    cheers
    boom! done! Booleans are sucky, integers do the same but with the added benefits of using math if you need to.
  • ericzingelerericzingeler Posts: 334
    Also, you can get creative with integer switches by using more than 2 states. In many cases, using more than 2 states on a switch can reduce the amount of attributes in your project.
  • tenrdrmertenrdrmer Posts: 9,934
    You just type in true or false for booleans no expression editor or anything

    Lowercase true or false is all you need for a Boolean.

    And yes integers are another good option but keep in mind they use a minuscule amount more ram from what I'm told so loads and loads of them could actually make a difference. But either way is really pretty good.
  • GamesITGamesIT Posts: 22
    edited August 2013
    Use this: (game.attribute)+true
    I get this work. I hope it work too for you
  • All you have to do is type in true or false. change attribute gameboolean to false
  • gyroscopegyroscope I am here.Posts: 6,577
    edited August 2013

    @igpxnaruto4

    ... or: 0 or 1.
  • IsabelleKIsabelleK Posts: 2,807
    Guys, guys, this thread is one year old :P Closing this.
This discussion has been closed.