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 Member Posts: 1,114
    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 Member Posts: 34

    @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 Member Posts: 34

    @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. Member Posts: 956

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

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

  • Wllew4GamesWllew4Games Member Posts: 34

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

  • Wllew4GamesWllew4Games Member Posts: 34

    so happy btw

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    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.Member Posts: 12,822

    @Wllew4Games said:
    so happy btw

    Like Kevin said much simpler way is . . .

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

  • Wllew4GamesWllew4Games Member Posts: 34

    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.