Animations¶
You can animate arbitrary objects using the function wasabi2d.animate()
.
For example, to move a primitive from its current position on the
screen to the position (100, 100)
:
animate(alien, pos=(100, 100))
- animate(object, tween='linear', duration=1, on_finished=None, **targets)¶
Animate the attributes on object from their current value to that specified in the targets keywords.
- Parameters
tween – The type of tweening to use.
duration – The duration of the animation, in seconds.
on_finished – Function called when the animation finishes.
targets – The target values for the attributes to animate.
The tween argument can be one of the following:
Name |
Description |
Plot (x = t, y = tween(t)) |
---|---|---|
|
Animate at a constant speed from start to finish |
|
|
Start slower and accelerate to finish |
|
|
Start fast and decelerate to finish |
|
|
Accelerate to mid point and decelerate to finish |
|
|
Give a little wobble at the end |
|
|
Have a little wobble at the start |
|
|
Have a wobble at both ends |
|
|
Accelerate to the finish and bounce there |
|
|
Bounce at the start |
|
|
Bounce at both ends |
The animate()
function returns an Animation
instance:
- class Animation¶
- stop(complete=False)¶
Stop the animation, optionally completing the transition to the final property values.
- Parameters
complete – Set the animated attribute to the target value.
- running¶
This will be True if the animation is running. It will be False when the duration has run or the
stop()
method was called before then.
- on_finished¶
You may set this attribute to a function which will be called when the animation duration runs out. The
on_finished
argument toanimate()
also sets this attribute. It is not called whenstop()
is called. This function takes no arguments.