Sliding button - is it possible?

digitalduriandigitaldurian Member Posts: 15
edited November -1 in Working with GS (Mac)
Hey there, I'm trying to do a pause button which 'slides' to another position when it's touched, and slides back when I touch it again. Kind of like a flip switch, which changes to another state when flipped and holds until I flip it back again.

Basically, this is what I have in mind. Do a Game boolean attribute: flipped, true or false

When touch released & flipped is false, change attribute flipped to true, interpolate to new_x for 0.5 secs
When touch is released & flipped is true, change to false and interpolate back to old_x for 0.5 secs
Forget about the pause part first, I can't even get the button to work so I want to solve this first.

In my puny mind, it seems logical to me, but it doesn't work when I tried it. How is it possible? Any ideas from the masters?

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    First off touch is released mean any time your not touching the screen that rule is triggered. so you have to rules firing back and forth non stop when your not touching because each rule switches itself to the other rule so you see nothing happening.

    So normally for buttons you want to use a touch is pressed rule

    Try this
    Make an integer attribute called flip

    Then a rule
    When touch is pressed
    --Change Attribute game.flip to (game.flip+1)%2

    Then a second rule

    When game.flip = 1
    --interpolate self.position.x to new.x
    Otherwise
    --interpolate self.position.x to old.x

    Hope that helps

    ___________________________________________________________________________________
    Project Help from Tenrdrmer Click Here

    GS BubbleBall Template HERE!!
    Stacks Level Selection Template HERE!!
    Expanding Option Menu Template HERE!!
    Tenrdrmer's Menu # 3 HERE!!
    Menu #4 - Level Banners HERE!!
    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
  • youngster9youngster9 Member Posts: 326
    tshirtbooth has a slide to play demo working check it out

    http://gamesalad.com/forums/topic.php?id=23253
  • digitalduriandigitaldurian Member Posts: 15
    @tenrdrmer - Thanks! That's EXACTLY what I need! I actually managed to achieve it this morning but using two actors and loads of confusion! Yours is much much more simpler! Almost 10 times simpler than what I did! Thanks, really!

    @youngster9 - Hey there it isn't exactly what I'm looking for but it's cool to know that tshirtbooth did something like that so thanks for sharing! Might be useful for my future projects!
Sign In or Register to comment.