AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzAnimTimeline Class Reference

CzAnimTimeline - An animation timeline. More...

#include <CzAnim.h>

Inheritance diagram for CzAnimTimeline:
IzXomlResource

List of all members.

Public Types

typedef CzList< CzAnimInstance * >
::iterator 
_Iterator

Public Member Functions

_Iterator begin ()
_Iterator end ()
void setManager (CzAnimTimelinesManager *manager)
CzAnimTimelinesManagergetManager ()
void setParent (IzXomlResource *parent)
IzXomlResourcegetParent ()
void addAnimation (CzAnimInstance *anim)
void removeAnimation (CzAnimInstance *anim)
CzAnimInstancefindAnimation (const char *name)
 Searches for the named animation.
CzAnimInstancefindAnimation (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

CzAnimTimelinesManagerManager
 Timeline manager that manages this timeline.
IzXomlResourceParent
 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.

Detailed Description

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:

XOML Example
<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" />
Code Example
// 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.


Member Typedef Documentation


Constructor & Destructor Documentation


Member Function Documentation

void CzAnimTimeline::addAnimation ( CzAnimInstance anim) [inline]

Searches for the named animation.

Parameters:
nameThe animation name.
Returns:
null if it fails, else the found animation.
CzAnimInstance * CzAnimTimeline::findAnimation ( unsigned int  name_hash)

Searches for the named animation.

Parameters:
nameThe animation name as a string hash.
Returns:
null if it fails, else the found animation.

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.

Parameters:
[in,out]targetIf non-null, the target.

Reimplemented from IzXomlResource.

float CzAnimTimeline::getTimeScale ( ) const [inline]
bool CzAnimTimeline::isAutoDelete ( ) const [inline]

Query if any animations within the instance are still playing.

Returns:
true if playing, false if not.

Query if all animations within the instance have stopped playing.

Returns:
true if stopped, false if not.
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.

Parameters:
[in]parentIf non-null, the parent.
load_childrentrue to load child nodes.
[in]nodeIf non-null, the XOML markup node that defines this object
Returns:
nergative value for error. if 0 then processing of further XOML will stop.

Implements IzXomlResource.

Pausesthe playback of all animations in the animation instance.

Plays all animations in the animation instance.

void CzAnimTimeline::Remove ( ) [virtual]

Removes and destroys this resource.

Reimplemented from IzXomlResource.

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]

Stops all animations in the animation instance.

bool CzAnimTimeline::Update ( float  time_delta,
IzAnimTarget target = NULL 
) [virtual]

Updates all animations in this timeline.

Parameters:
time_deltaThe time delta.
[in,out]targetIf non-null, the target.
Returns:
true if any animation instances are still playing, false if all have finished playing
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.

Parameters:
[in,out]targetIf non-null, the target.

Member Data Documentation

Animation intsnces.

bool CzAnimTimeline::AutoDelete [protected]

If set to true thenm timeline will be deleted when finished.

Timeline manager that manages this timeline.

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)


The documentation for this class was generated from the following files: