(Docs) Adding Programming Guide to Toolkit
[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.OpacityTo(actor, 1.0f);
24    myAnimation.MoveTo(actor, 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    For actor there exists a range of methods ranging from Move, Rotate, Scale, Opacity, Color to Resize.  The API explains in detail what each does and the parameters to these methods but there are some points worth noting;
34
35    xxxxBy and xxxxTo, 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 MoveBy(actor, 50,0,0) would mean its location is (60,0,0) whilst MoveTo(actor, 50,0,0) would result in a location (50,0,0).
36
37    Dali::AlphaFunctions 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::AlphaFunctions::EaseInOutSine instead of AlphaFunctions::Linear.
38
39    @code
40    myAnimation.MoveTo(actor, Vector3(x, y, z), AlphaFunctions::Linear, delay, ANIMATOR_DURATION);
41    myAnimation.Resize(actor, actorSize, AlphaFunctions::EaseIn, delay, ANIMATOR_DURATION);
42    @endcode
43    \section playback-control Controlling a playing animation
44
45    The 3 controls we have are start, pause and stop
46    @code
47    Dali::Animation::Play();
48    Dali::Animation::Stop();
49    Dali::Animation::Pause();
50    @endcode
51
52    \section default-settings Default settings
53    The call Dali::Animation::New provides some default settings but each has a setter function if the defaults are not suitable. (Getters also exist)
54    @code
55    Dali::Animation::SetEndAction
56    Dali::Animation::SetLooping
57    Dali::Animation::SetDefaultAlphaFunction
58    @endcode
59
60    \section end-signal End Signal
61    The following signal can be connected to if it is required to know when an animation is complete.
62    /code Dali::Animation::SignalFinish(); /endcode
63
64  */
65