hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 117 forks source link

Pause animation using Interpolator #114

Closed Jeyabalan closed 11 years ago

Jeyabalan commented 11 years ago

In my case i need an object to reach finish line and come back with constant speed. I may allow the user to pause the object from moving at any point during this action.

If i use interpolator for this action, is their a way to pause the object motion and revoke moving with the same interpolation already declared in the path behavior ?

hyperandroid commented 11 years ago

could you post an specific use case of what you want ?

thanks. On Jan 9, 2013 9:07 PM, "Jeyabalan" notifications@github.com wrote:

Is there any way to pause the animation using any of the interpolator?

— Reply to this email directly or view it on GitHubhttps://github.com/hyperandroid/CAAT/issues/114.

Jeyabalan commented 11 years ago

In my case i need an object to reach finish line and come back with constant speed. I may allow the user to pause the object from moving at any point during this action.

If i use interpolator for this action, is their a way to pause the object motion and revoke moving with the same interpolation already declared in the path behavior ?

hyperandroid commented 11 years ago

Your best option is to define an interpolator with the parameter pingpong= true. this makes interpolators to be simmetric on time, taking half the time to traverse in one direction, and the other half time to get back to the origin. Unfortunately, CAAT is based in a timeline, and you can't pause the timer for just one Actor attribute like an interpolator. On the other hand, interpolators have a function: setTimeOffset( number<0..1> ) which make an interpolator to start in a different position than in the origin. You should infer the value to setTimeOffset from your actor's current position, and either build a new Behavior, or call setDelayTime(0,time_to_traverse_the_behavior) again to restart the behavior.

Thanks.