diff --git a/doc/cookbook/animations.xml b/doc/cookbook/animations.xml index 95bb02975..628a57f35 100644 --- a/doc/cookbook/animations.xml +++ b/doc/cookbook/animations.xml @@ -2372,7 +2372,7 @@ clutter_actor_animate_with_timeline (actor, - One further technique is to swop the timeline's + One further technique is to repeatedly reverse the timeline's direction to create a "closed loop" animation (one which returns to its origin at the end of each iteration). See this @@ -2655,12 +2655,23 @@ timeline_completed_cb (ClutterTimeline *timeline, animations, one the inverse of the other, and chaining them together. However, a simpler solution is to run forward through the timeline - once; then invert its direction when the end of timeline is reached. - The animation continues, but in reverse. Once the backward iteration - completes, set the timeline to run forward again. Keep changing the - timeline's direction each time it completes. This - is the approach used in the - example, which results in a smooth, repeated right to left, + once, and have the timeline invert itself when its end is reached. + The animation then continues, but in reverse. Once the backward iteration + completes, the timeline sets itself to run forward again, etc. + + To make a timeline reverse its direction each time it + completes, use the clutter_timeline_set_reverse() + function: + + + +clutter_timeline_set_reverse (timeline, TRUE); + + + + This is the approach used in + the example, + which results in a smooth, repeated right to left, left to right motion. See this diff --git a/doc/cookbook/examples/animations-looping-implicit.c b/doc/cookbook/examples/animations-looping-implicit.c index 15eb00953..98bc58818 100644 --- a/doc/cookbook/examples/animations-looping-implicit.c +++ b/doc/cookbook/examples/animations-looping-implicit.c @@ -10,20 +10,6 @@ typedef struct ClutterTimeline *timeline; } State; -static void -invert_timeline_cb (ClutterTimeline *timeline, - gpointer user_data) -{ - ClutterTimelineDirection direction = clutter_timeline_get_direction (timeline); - - if (direction == CLUTTER_TIMELINE_FORWARD) - direction = CLUTTER_TIMELINE_BACKWARD; - else - direction = CLUTTER_TIMELINE_FORWARD; - - clutter_timeline_set_direction (timeline, direction); -} - static gboolean key_pressed_cb (ClutterActor *actor, ClutterEvent *event, @@ -63,21 +49,13 @@ main (int argc, state->timeline = clutter_timeline_new (1000); clutter_timeline_set_loop (state->timeline, TRUE); + clutter_timeline_set_reverse (state->timeline, TRUE); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_pressed_cb), state); - /* the animation will not emit a "completed" signal, - * as it is set to loop; but the timeline emits "completed" - * at the end of each iteration of the loop - */ - g_signal_connect (state->timeline, - "completed", - G_CALLBACK (invert_timeline_cb), - NULL); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), state->actor); clutter_actor_show (stage);