AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
CzAnimTimeline - An animation timeline. More...
#include <CzAnim.h>
Public Types | |
typedef CzList< CzAnimInstance * > ::iterator | _Iterator |
Public Member Functions | |
_Iterator | begin () |
_Iterator | end () |
void | setManager (CzAnimTimelinesManager *manager) |
CzAnimTimelinesManager * | getManager () |
void | setParent (IzXomlResource *parent) |
IzXomlResource * | getParent () |
void | addAnimation (CzAnimInstance *anim) |
void | removeAnimation (CzAnimInstance *anim) |
CzAnimInstance * | findAnimation (const char *name) |
Searches for the named animation. | |
CzAnimInstance * | findAnimation (unsigned int name_hash) |
Searches for the named animation. | |
void | play () |
Plays all animations in the animation instance. | |
void | stop () |
Stops all animations in the animation instance. | |
void | pause () |
Pausesthe playback of all animations in the animation instance. | |
void | restart () |
Restarts all animations in the animation instance. | |
int | getAnimationCount () |
void | setTargetElement (IzAnimTarget *target) |
bool | isStopped () |
Query if all animations within the instance have stopped playing. | |
bool | isPlaying () |
Query if any animations within the instance are still playing. | |
void | setAutoDelete (bool enable) |
bool | isAutoDelete () const |
void | setTimeScale (float time_scale) |
float | getTimeScale () const |
CzAnimTimeline () | |
virtual | ~CzAnimTimeline () |
virtual void | ForceUpdateTargetOnly (IzAnimTarget *target=NULL) |
Force update all animations in the timeline (targets only). | |
virtual void | UpdateTargetOnly (IzAnimTarget *target=NULL) |
Updates all animations in the timeline (targets only). | |
virtual bool | Update (float time_delta, IzAnimTarget *target=NULL) |
Updates all animations in this timeline. | |
int | LoadFromXoml (IzXomlResource *parent, bool load_children, CzXmlNode *node) |
Creates an instance of this class from XOML. | |
void | SetCurrentTime (float current_time) |
void | Remove () |
Removes and destroys this resource. | |
Static Public Member Functions | |
static void | UpdateRunCount () |
Protected Attributes | |
CzAnimTimelinesManager * | Manager |
Timeline manager that manages this timeline. | |
IzXomlResource * | Parent |
Parent container TODO: REMOVE Parent, this is stored in Container in IzXomlResource. | |
CzList< CzAnimInstance * > | Animations |
Animation intsnces. | |
float | TimeScale |
How to scale time (1 - no change, > 1 speed up time, < 1 slow down time) | |
bool | AutoDelete |
If set to true thenm timeline will be deleted when finished. |
CzAnimTimeline - An animation timeline.
An animation time line is basically a way to group together multiple animation instances and play, pause, stop and resume them all together. The general idea is that you create an animation time line then create animation instances and add them to the time line. You then attach the time line to your destination object, be that a scene or an actor. The animation system will then take care of the rest for you. Here is an example showing how to create and use a time line:
<Animation Name="ang_anim" Duration="5" Type="float"> <Frame Time="0" Value="0" /> <Frame Time="2.5" Value="180" /> <Frame Time="5" Value="0" /> </Animation> <Timeline Name="spin_anim" AutoPlay="true"> <Animation Anim="ang_anim" Repeat="0" Target="Angle" /> </Timeline> <Label Font="serif" Text="Hello" Timeline="spin_anim" />
// Create angle animation CZ_NEW_ANIM(ang_anim, "ang_anim", 5, CzAnimFrame::FT_Float); CZ_NEW_ANIM_FRAME_FLOAT(ang_anim, 0, 0, CzAnimFrame::AT_Linear); CZ_NEW_ANIM_FRAME_FLOAT(ang_anim, 2.5, 180, CzAnimFrame::AT_Linear); CZ_NEW_ANIM_FRAME_FLOAT(ang_anim, 5, 0, CzAnimFrame::AT_Linear); scene->getResourceManager()->addResource(ang_anim); // Create animation timeline CZ_NEW_TIMELINE(spin_anim, "spin_anim", ang_anim, 0, true, 0, "Angle"); label->getTimelinesManager()->addTimeline(spin_anim); // Assign timeline to scene and start the animation scene->setTimeline(spin_anim); spin_anim->restart();
In the above examples we create an animation then assign it to a timeline. We then assign the timeline to the label which causes it to spin over 5 seconds.
Defining and attaching animations is much easier and more intuitive if done declaratively using XOML mark-up.
Note that when you attach an animation time line to a scene or an actor, the scene / actor will automatically take over updating it for you.
Time lines can be played, paused, resumed and stopped. All animation instances within the animation time line will be affected.
typedef CzList<CzAnimInstance*>::iterator CzAnimTimeline::_Iterator |
CzAnimTimeline::CzAnimTimeline | ( | ) | [inline] |
CzAnimTimeline::~CzAnimTimeline | ( | ) | [virtual] |
void CzAnimTimeline::addAnimation | ( | CzAnimInstance * | anim | ) | [inline] |
_Iterator CzAnimTimeline::begin | ( | ) | [inline] |
_Iterator CzAnimTimeline::end | ( | ) | [inline] |
CzAnimInstance * CzAnimTimeline::findAnimation | ( | const char * | name | ) |
Searches for the named animation.
name | The animation name. |
CzAnimInstance * CzAnimTimeline::findAnimation | ( | unsigned int | name_hash | ) |
Searches for the named animation.
name | The animation name as a string hash. |
void CzAnimTimeline::ForceUpdateTargetOnly | ( | IzAnimTarget * | target = NULL | ) | [virtual] |
Force update all animations in the timeline (targets only).
This method force updates all animation instance targets in this timeline, even if the animation is not playing.
[in,out] | target | If non-null, the target. |
int CzAnimTimeline::getAnimationCount | ( | ) | [inline] |
CzAnimTimelinesManager* CzAnimTimeline::getManager | ( | ) | [inline] |
IzXomlResource* CzAnimTimeline::getParent | ( | ) | [inline] |
Reimplemented from IzXomlResource.
float CzAnimTimeline::getTimeScale | ( | ) | const [inline] |
bool CzAnimTimeline::isAutoDelete | ( | ) | const [inline] |
bool CzAnimTimeline::isPlaying | ( | ) |
Query if any animations within the instance are still playing.
bool CzAnimTimeline::isStopped | ( | ) |
Query if all animations within the instance have stopped playing.
int CzAnimTimeline::LoadFromXoml | ( | IzXomlResource * | parent, |
bool | load_children, | ||
CzXmlNode * | node | ||
) | [virtual] |
Creates an instance of this class from XOML.
LoadFromXoml is the main method used by all classes that can be instantiated from XOML mark-up. This method creates an instance of this class from the supplied XML node structure specified by node.
[in] | parent | If non-null, the parent. |
load_children | true to load child nodes. | |
[in] | node | If non-null, the XOML markup node that defines this object |
Implements IzXomlResource.
void CzAnimTimeline::pause | ( | ) |
Pausesthe playback of all animations in the animation instance.
void CzAnimTimeline::play | ( | ) |
Plays all animations in the animation instance.
void CzAnimTimeline::Remove | ( | ) | [virtual] |
Removes and destroys this resource.
Reimplemented from IzXomlResource.
void CzAnimTimeline::removeAnimation | ( | CzAnimInstance * | anim | ) | [inline] |
void CzAnimTimeline::restart | ( | ) |
Restarts all animations in the animation instance.
void CzAnimTimeline::setAutoDelete | ( | bool | enable | ) | [inline] |
void CzAnimTimeline::SetCurrentTime | ( | float | current_time | ) | [inline] |
void CzAnimTimeline::setManager | ( | CzAnimTimelinesManager * | manager | ) | [inline] |
void CzAnimTimeline::setParent | ( | IzXomlResource * | parent | ) | [inline] |
void CzAnimTimeline::setTargetElement | ( | IzAnimTarget * | target | ) | [inline] |
void CzAnimTimeline::setTimeScale | ( | float | time_scale | ) | [inline] |
void CzAnimTimeline::stop | ( | ) |
Stops all animations in the animation instance.
bool CzAnimTimeline::Update | ( | float | time_delta, |
IzAnimTarget * | target = NULL |
||
) | [virtual] |
Updates all animations in this timeline.
time_delta | The time delta. | |
[in,out] | target | If non-null, the target. |
static void CzAnimTimeline::UpdateRunCount | ( | ) | [inline, static] |
void CzAnimTimeline::UpdateTargetOnly | ( | IzAnimTarget * | target = NULL | ) | [virtual] |
Updates all animations in the timeline (targets only).
This method updates all animation instance targets only.
[in,out] | target | If non-null, the target. |
CzList<CzAnimInstance*> CzAnimTimeline::Animations [protected] |
Animation intsnces.
bool CzAnimTimeline::AutoDelete [protected] |
If set to true thenm timeline will be deleted when finished.
CzAnimTimelinesManager* CzAnimTimeline::Manager [protected] |
Timeline manager that manages this timeline.
IzXomlResource* CzAnimTimeline::Parent [protected] |
Parent container TODO: REMOVE Parent, this is stored in Container in IzXomlResource.
Reimplemented from IzXomlResource.
float CzAnimTimeline::TimeScale [protected] |
How to scale time (1 - no change, > 1 speed up time, < 1 slow down time)