Merge "Programming Guide Updates" into tizen
[platform/core/uifw/dali-toolkit.git] / docs / content / programming-guide / animation-example.h
1 /*! \page animation-example Example and Usage
2
3    We will start by showing the steps for animating an actors position and opacity so the actor moves whilst the opacity changes.
4
5    Next more interesting animations methods (effects) with individual timing will be explained.
6
7    \section simple-anim Simple Animation moving an actor whilst altering opacity.
8
9    We declare an animation called myAnimation
10
11    @code
12    Dali::Animation myAnimation
13    @endcode
14
15    A new animation instance is created with a specified duration.  Here the duration of the animation will be 0.5 seconds.
16    Some other settings are incorporated by default and will be explained later.
17    @code
18    myAnimation = Animation::New(0.5f);
19    @endcode
20
21    Here we add the animators, these are the building blocks (functions) of the animation and define what we want to see
22    @code
23    myAnimation.AnimateTo(Property(actor, Actor::Property::OPACITY), 1.0f);
24    myAnimation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(x, y, z));
25    @endcode
26
27    start animation, when this is called we want the animation to start playing so here the actor will move whilst the opacity changes.
28    @code
29    myAnimation.Play();
30    @endcode
31    \section advanced-anims Adding more advanced animators, if simply moving the actor is not enough we have further animations methods.
32
33    AnimateBy and AnimateTo, method names are appended by 'By' or 'To' either animate to a supplied value or animate by a supplied value.  For example an actor at (10,10,10) calling AnimateBy(Property(actor, Actor::Property::POSITION), 50,0,0) would mean its location is (60,0,0) whilst AnimateTo(Property(actor, Actor::Property::POSITION), 50,0,0) would result in a location (50,0,0).
34
35    Dali::AlphaFunction can be used to give interesting effects to the animation, for example the MOVEment of an actor on screen can speed up and slow down following a sine curve by using the Dali::AlphaFunction::EASE_IN_OUT_SINE instead of AlphaFunction::LINEAR
36
37    @code
38    myAnimation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(x, y, z), AlphaFunction::LINEAR, delay, ANIMATOR_DURATION);
39    myAnimation.AnimateTo(Property(actor, Actor::Property::SIZE), actorSize, AlphaFunction::EASE_IN, delay, ANIMATOR_DURATION);
40    @endcode
41    \section playback-control Controlling a playing animation
42
43    The 3 controls we have are start, pause and stop
44    @code
45    Dali::Animation::Play();
46    Dali::Animation::Stop();
47    Dali::Animation::Pause();
48    @endcode
49
50    \section default-settings Default settings
51    The call Dali::Animation::New provides some default settings but each has a setter function if the defaults are not suitable. (Getters also exist)
52    @code
53    Dali::Animation::SetEndAction
54    Dali::Animation::SetLooping
55    Dali::Animation::SetDefaultAlphaFunction
56    @endcode
57
58    \section end-signal End Signal
59    The following signal can be connected to if it is required to know when an animation is complete.
60    /code Dali::Animation::SignalFinish(); /endcode
61
62  */
63