![]() |
![]() |
![]() |
Clutter 0.9.2 Reference Manual | ![]() |
---|
Using behaviours for simple animations of a single actor may be too complicated, in terms of memory management and bookkeeping of the object instances. For this reason, Clutter also provides a simple animation API for implicit animations using properties of an actor: clutter_actor_animate().
The clutter_actor_animate() family of functions will create and use an implicit #ClutterAnimation instance, which will then handle the animation of one or more #ClutterActor properties between a range of values.
Example 11.
The following example demonstrates how to use the clutter_actor_animate() method to tween an actor between the current position and a new set of coordinates. The animation takes 200 milliseconds to complete and uses a linear speed.
clutter_actor_animate (actor, CLUTTER_LINEAR, 200 "x", 200, "y", 200, NULL);
The clutter_actor_animate() method returns a #ClutterAnimation instance that can be used to start, stop and modify the animation while it's running. The #ClutterAnimation::completed signal will be emitted when the animation has been completed.
When the animation is complete it will be automatically unreferenced, and disposed if nothing else is holding a reference on it.
Calling clutter_actor_animate() multiple times on an actor which is being animated will cause the animation to be updated with the new values.
Example 12.
The following example demonstrates how to animate an actor inside the signal handler for a button press event. If the user presses the button on a new position while the animation is running, the animation will be restarted with the new final values updated.
static gboolean on_button_press (ClutterActor *actor, ClutterButtonEvent *event, gpointer user_data) { clutter_actor_animate (actor, CLUTTER_EASE_SINE_OUT, 500, "x", event->x, "y", event->y, NULL); return TRUE; }