4 # Animation {#animation}
6 DALi provides a rich and easy to use animation framework which allows the creation of visually rich applications.
7 Dali::Animation can be used to animate the properties of any number of objects, typically Actors.
9 ## Creating a basic Animation {#animation-basics}
11 Create an animation object that will take place over 3 seconds:
13 Dali::Animation animation = Animation::New( 3.0f );
16 ### Animating Properties
18 There are two distint ways in which properties can be animated within DALi:
19 - **AnimateTo:** The property will animate **TO** the value in the given time.
20 - **AnimateBy:** The property will animate **BY** the value in the given time.
22 (Assume actor1 & actor2 are at position 10.0f, 10.0f, 0.0f at the start of the animation)
24 // Animate the position of actor1 TO 10.0f, 50.0f, 0.0f
25 animation.AnimateTo( Property( actor1, Dali::Actor::Property::POSITION ), Vector3(10.0f, 50.0f, 0.0f) ); // End Position: 10.0f, 50.0f, 0.0f
27 // Animate the position of actor2 BY 10.0f, 50.0f, 0.0f
28 animation.AnimateBy( Property( actor2, Dali::Actor::Property::POSITION ), Vector3(10.0f, 50.0f, 0.0f) ); // End Position: 20.0f, 60.0f, 0.0f
33 When an animation is created, it can be played:
38 Stop and Pause are also supported.
46 Using DALi's signal framework, applications can be notified when the animation finishes:
50 void ExampleCallback( Animation& source )
52 std::cout << "Animation has finished" << std::endl;
55 animation.FinishedSignal().Connect( ExampleCallback );
60 Alpha functions are used in animations to specify the rate of change of the animation parameter over time.
61 The built in supported functions can be viewed in Dali::AlphaFunction::BuiltinFunction.
63 It is possible to specify a different alpha function for each animator in an Animation object:
65 animation.AnimateTo( Property( actor1, Dali::Actor::Property::POSITION ), Vector3(10.0f, 50.0f, 0.0f), Dali::AlphaFunction::EASE_IN );
70 An animation can be looped:
72 animation.SetLooping( true );
75 By default, when an animation ends, the properties that it was animating are BAKED.
76 However, the property changes can be **discarded** when the animation ends (or is stopped):
78 animation.SetEndAction( Animation::Discard );
81 ## Key-Frame Animation {#animation-key-frame}