Emmanuele Bassi
ebassi@linux.intel.com
Migrating from ClutterBehaviour The #ClutterBehaviour class and its sub-classes have been deprecated since Clutter 1.6. The animation framework provided by #ClutterAnimation, #ClutterAnimator and #ClutterState fully replaces all functionality from the #ClutterBehaviour classes. Generally, animations using #ClutterBehaviour sub-classes can be effectively re-implemented just by using #ClutterActor properties. Here is an example of an animation using a #ClutterBehaviourOpacity instance: ClutterTimeline *timeline = clutter_timeline_new (250); ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); ClutterBehaviour *behaviour = clutter_behaviour_opacity_new (alpha, 255, 0); clutter_behaviour_apply (behaviour, some_actor); clutter_timeline_start (timeline); The same effect can be achieved by using clutter_actor_animate() and the #ClutterActor:opacity property: clutter_actor_set_opacity (some_actor, 255); clutter_actor_animate (some_actor, CLUTTER_LINEAR, 250, "opacity", 0, NULL); #ClutterBehaviours used for continuous animations with looping timelines can still be effectively replaced by looping animations; for instance, the following example of a "pulsating" actor using #ClutterBehaviourScale: static void reverse_timeline (ClutterTimeline *timeline) { ClutterTimelineDirection dir = clutter_timeline_get_direction (timeline); if (dir == CLUTTER_TIMELINE_FORWARD) dir = CLUTTER_TIMELINE_BACKWARD; else dir = CLUTTER_TIMELINE_FORWARD; clutter_timeline_set_direction (timeline, dir); } ClutterTimeline *timeline = clutter_timeline_new (500); ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); ClutterBehaviour *behaviour; g_object_set (some_actor, "scale-gravity", CLUTTER_GRAVITY_CENTER, NULL); behaviour = clutter_behaviour_scale_new (alpha, 1.0, 2.0, 1.0, 2.0); clutter_behaviour_apply (behaviour, some_actor); g_signal_connect (timeline, "completed", G_CALLBACK (reverse_timeline), NULL); clutter_timeline_set_loop (timeline); clutter_timeline_start (timeline); The same effect can be achieved using a #ClutterAnimation: ClutterAnimation *animation = clutter_actor_animate (some_actor, CLUTTER_LINEAR, 500, "scale-x", 2.0, "scale-y", 2.0, "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER, NULL); ClutterTimeline *timeline = clutter_animation_get_timeline (animation); clutter_timeline_set_repeat_count (timeline, -1); clutter_timeline_set_auto_reverse (timeline, TRUE); #ClutterBehaviour sub-classes can be applied to multiple actors, in order to share the duration and the easing mode. It is possible to use the same underlying #ClutterTimeline and #ClutterAlpha instances with #ClutterAnimation to achieve the same effect. Complex animations, spanning multiple actors, should use the #ClutterAnimator and #ClutterState classes instead.