Problem with touch released

ChillBoxChillBox Member, PRO Posts: 115
edited January 2013 in Working with GS (Mac)
hi all,
I have a problem with this rule.
http://img846.imageshack.us/img846/9785/screenshot20130107at320.png

if touch released but the attribute "coins" is less then 1000 so nothing it's happening,
but when the attribute "coins" is more then 1000 the rule is happening without touch released.
because i touche released earlier. (It's like the "release" were saved.)
I want that when touch is released and its more then 1000 coins that the rule will happen.

Sorry if my English was shaky.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    Hi @talo it's probably best to nest a rule within a touch rule only if you're going to use the Otherwise section; or if there are more rules to nest; so in this case, there's no need to: try putting the two conditions together in the same rule:

    When touch is released and game.coin => 1000
    Play Sound
    Change Image
    Timer

    Another way: If you did want to keep the rules nested, I think making the first Rule as When touch is pressed would work OK...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ChillBoxChillBox Member, PRO Posts: 115
    But i need that to be touch is released.
    there is another way?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi, did you try it with the two conditions in the same Rule?:

    When touch is released and game.coin => 1000
    Play Sound
    Change Image
    Timer

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • LumpAppsLumpApps Member Posts: 2,881
    Talo if i understand you well your problem is that when the coins reach 1000 the action is triggered when the release is triggered earlier in the scenes time.
    While I too had difficulties understanding this is the right behavior. When an actor is released it stays released.
    The workaround for you would be
    Add a real attribute and name it Releasetime
    Then a rule:
    When actor is touched change attribute Releasetime to self.time

    Then make a rule:
    (All)
    When actor is released
    When self.time is < Releasetime + 0.2
    When coins >= 1000
    Do something

    I am doing this from memory so I hope the above is correct.
  • ashtmjashtmj Member, PRO Posts: 405
    in my experience most times you have a button you need a extra rule in your button actor

    Boolean called "Pressed"

    rule 1

    when touch is pressed
    change self.attribute "Pressed" to true

    Rule 2
    conditions :

    *if touch is released
    * self.attribute Pressed is true
    *coins => then 1000

    Then add a timer
    after 0 secs (run to completion checked)

    what ever you want to happen followed by
    change self.attribute "Pressed" to false

    its good to have this within a timer because, lets say this is your action:

    change game.coins to games.coin-1000

    change self.attribute "Pressed" to false

    if the "coins" go below 1000 (the needed amount within the rules conditions)
    it won't set pressed to false without the timer because one of the conditions will no longer be true.



  • LumpAppsLumpApps Member Posts: 2,881
    That is correct. I believe i did the same thing but a little different (using a custom timer).
    Both ways should work. I try to avoid timers because they consume a lot of processing speed.
  • ChillBoxChillBox Member, PRO Posts: 115
    edited January 2013
    Thank you very much! @ashtmj
    and all of you guys!
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Yes, touch is released works like turning a switch on permanently as touch is pressed is momentary.
  • AdvenireSoftwareAdvenireSoftware David Russell Pennsylvania, USMember, PRO Posts: 4

    Thanks for the posts. I just ran into this issue. I thought it might have been a bug. Thanks for the work around. I'm going to try them in my current game.

Sign In or Register to comment.