Timer Confusion?

TotalityNodeTotalityNode Member Posts: 5
edited July 2012 in Working with GS (Mac)
Hi all, n00b to GS here, and I've found I've just not got my head round the timing of events etc.

I've got an Actor, that when pressed, I simply want to rotate counter-clockwise 45 degrees quickly, then a little slower return to 0 degrees rotated. Essentially, the Actor 'brakes/decelerates' when you tap it.

I've tried a couple of Timers for this, but the behaviour in Preview is erratic.

Rule etc:
---------------------------------------------

- Rule DECELERATE
When All conditions are valid:
Actor receives event touch is pressed

- Timer
After 0 seconds Ticked Run to Completion

- Interpolate
self.Rotation to: 45
Duration 0.1


- Timer
After 0.1 seconds Ticked Run to Completion

- Interpolate
self.Rotation to: 0
Duration 0.5
---------------------------------------------

So sometimes the Actor performs as desired, sometimes it just rotates a few degrees before returning to 0, sometimes stays rotated, sometimes flips out and spins right round. Whether this is based on the event being 'pressed' I do not know.

What am I just not getting, guys?

Many many thanks in advance.

Best Answers

  • JustMe74JustMe74 Posts: 542
    Accepted Answer
    Do you want to have to continue to hold your finger on the actor? If not, change the rule to when touch is released, rather than pressed.
  • MotherHooseMotherHoose Posts: 2,456
    Accepted Answer
    problem is probably when touch is continuously pressed:
    … Timer1 fires continuously

    IMO timers are not needed for these rotations (Interpolate has a timed duration)

    objectives:
    when: touch is pressed; when self.Rotation = 0
    what: Interpolate: self.Rotation To: 45

    when: touch is released; when self.Rotation ≥ 45
    what: Interpolate: self.Rotation To: 0

    that can be written as one rule with touch released in its Otherwise: section
    or 2 separate rules

    setting Interpolate's Function: Ease in/out … makes this smooth

    image MH

Answers

  • TotalityNodeTotalityNode Member Posts: 5
    Brilliant, thanks both!

    'Rising' really nicely when it brakes now.
Sign In or Register to comment.