GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Help With Toggle

I need to know how to make it so when I touch an actor, it changes an attribute from 0 to 1 or from 1 to 0
Please Help! :smiley:

Comments

  • ChunkypixelsChunkypixels Posts: 1,113Member
    edited September 2015

    create a boolean attribute... call it whatever you want... for arguments sake we'll call it ButtonToggle

    On your button actor have the following rule:

    When ALL conditions are valid:
    Actor receives event Touch is pressed
    When ButtonToggle is False
    Change Attribute ButtonToggle to True

    Then set up whatever it triggers to activate when ButtonToggle is True.

    To use the same button to switch the trigger off add the following to your button actor:

    When ALL conditions are valid:
    Actor receives event Touch is pressed
    When ButtonToggle is True
    Change Attribute ButtonToggle to False

  • Wllew4GamesWllew4Games Posts: 34Member

    @Chunkypixels said:
    create a boolean attribute... call it whatever you want... for arguments sake we'll call it ButtonToggle

    On your button actor have the following rule:

    When ALL conditions are valid:
    Actor receives event Touch is pressed
    When ButtonToggle is False
    Change Attribute ButtonToggle to True

    Then set up whatever it triggers to activate when ButtonToggle is True.

    To use the same button to switch the trigger off add the following to your button actor:

    When ALL conditions are valid:
    Actor receives event Touch is pressed
    When ButtonToggle is True
    Change Attribute ButtonToggle to False

    The First toggle worked fine, but when I tried to toggle it back, it stayed the same :(

  • Wllew4GamesWllew4Games Posts: 34Member

    @Wllew4Games said:
    The First toggle worked fine, but when I tried to toggle it back, it stayed the same :(

    The change attribute didn't work.

  • RabidParrotRabidParrot Formally RabidParrot. Posts: 956Member
  • RThurmanRThurman Posts: 2,824Member, Sous Chef, PRO

    Here is a file with four different examples of how to do it. (There are probably several more.)

  • Wllew4GamesWllew4Games Posts: 34Member

    I FIGURED IT OUT!!!! :D :D :D :D :D :D

  • Wllew4GamesWllew4Games Posts: 34Member

    so happy btw

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    This is by far the best and shortest toggle in my opinion:

    Change Attribute: game.toggle = 1 - game.toggle.

    game.toggle (or whatever you want to call it) needs to be an index or integer.

  • SocksSocks London, UK.Posts: 12,822Member

    @Wllew4Games said:
    so happy btw

    Like Kevin said much simpler way is . . .

    When Touch is pressed
    --Change A to 1-A

  • Wllew4GamesWllew4Games Posts: 34Member

    It used to work with what I said before but game salad updated and now I can't seem to get it to work.

Sign In or Register to comment.