Button - touch & release

IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
edited January 2012 in Working with GS (Mac)
Hi guys!
I have a problem with my button - I want it to work like this - when button is pressed, and THEN touch is released, camera changes its origin.

It's pretty easy, I have a rule:

If TOUCH is PRESSED, and Camera Origin is X
Timer - after 0.1 second (run to completion)
If TOUCH is RELEASED, and Camera Origin is X
Change attribute Camera Origin to Y

It works fine to change Camera from X to Y, BUT when I get the Camera back to X, it's automatically changes Camera to Y.

And I have no idea how to fix it.

Could you give me a hand?

Thank you!

Comments

  • POMPOM Member Posts: 2,599
    edited January 2012
    Why not simply use touch is released?

    If TOUCH is RELEASED, and Camera Origin is X
    Change attribute Camera Origin to Y

    Roy.
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Thank you for your reply Roy!

    I can do it, but it doesn't work either:

    If TOUCH is RELEASED, and Camera Origin is X
    Change attribute Camera Origin to Y

    It works fine to change Camera from X to Y, BUT when I get the Camera back to X, it's automatically changes Camera to Y.
  • POMPOM Member Posts: 2,599
    edited January 2012
    Ok , I see what is going on .
    I suggest this :

    Create a self attribute - boolean - call it "im touched"

    Then a rule , when touch is pressed
    Change "self.im touched" to true
    After 0.2 (run to completion) change "self.im touched" to false

    Now another different rule (not nested):
    when "self.im touched" IS true
    When touch is released
    Change attribute Camera Origin to Y

    It should work i hope

    Roy.
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    It works! Thank you very much Roy! :)
  • simo103simo103 Member, PRO Posts: 1,331
    edited January 2012
    can someone help me understand this a little more? For example ... a scene loads with a button that has 'touch is pressed' and 'touch is released' rules. Once that button is set as 'released' is there a way to reset it to the state it is when first loaded ie: not released? I think perhaps Roy's example above might solve it in some cases but in my game the button is pressed and held to spin a wheel, the length of time is as long as the player wants, and then release triggers some actions. All of those rules needs to be reset so the player can do it again and again. Any ideas?
Sign In or Register to comment.