JAnimator Class Reference

#include <JAnimator.h>

List of all members.

Public Member Functions

 JAnimator (JResourceManager *resourceMgr)
 ~JAnimator ()
bool Load (const char *scriptFile)
void Start ()
void Stop ()
void Pause ()
void Resume ()
void Update (float dt)
void Render ()
bool IsAnimating ()
bool IsActive ()
void SetCurrentFrameIndex (int index)
int GetCurrentFrameIndex ()
void SetAnimationType (int type)
void SetPosition (float x, float y)
void SetHotSpot (float x, float y)


Detailed Description

A frame based animation system. The animation frames and play sequence are loaded from a XML file.

A sample animation script:

        <?xml version="1.0" standalone="no" ?>

        <script name="abc" type="ANIMATION_TYPE_ONCE_AND_STAY" framerate="20">

"type" can be ANIMATION_TYPE_LOOPING, ANIMATION_TYPE_ONCE_AND_STAY, ANIMATION_TYPE_ONCE_AND_BACK, ANIMATION_TYPE_ONCE_AND_GONE or ANIMATION_TYPE_PINGPONG

"framerate" is the rate of playback in frames per seconds.

        <frame id="1">
                <obj name="head">
                        <settings quad="head" x="10" y="10" hsize="1.0" vsize="1.0" rotation="0.0" r="255" g="255" b="255" a="255" />
                </obj>
                <obj name="body">
                        <settings quad="body" />
                </obj>
        </frame>

Each frame contains one or more frame objects. Each object is a quad with various settings. "quad" is the name of the quad. "x" and "y" is the position. "hsize" is the horizontal scaling and "vsize" is the vertical scaling. "rotation" is the angle that the quad will be rotated in radians. You can also specify the color and alpha of the quad with the "r", "g", "b" and "a" parameters.

        <frame id="2" time="0.20">
                <obj name="head">
                        <settings quad="head" x="10" y="10" hsize="1.0" vsize="1.0" rotation="0.0" r="255" g="255" b="255" a="255" />
                </obj>
                <obj name="body">
                        <settings quad="body" a="128" />
                </obj>
        </frame>

        
 </script>

A frame can also overide the global frame rate by using the "time" parameter (in second) as shown above.


Constructor & Destructor Documentation

JAnimator::JAnimator ( JResourceManager *  resourceMgr  ) 

Constructor.

Parameters:
resourceMgr - ResourceManager to look for images (JQuads)

JAnimator::~JAnimator (  ) 

Destructor.


Member Function Documentation

bool JAnimator::Load ( const char *  scriptFile  ) 

Load animation sequence from a script file.

Parameters:
scriptFile - Animation script.
Returns:
True if no problem during loading. False otherwise.

void JAnimator::Start (  ) 

Start animation.

void JAnimator::Stop (  ) 

Stop animation.

void JAnimator::Pause (  ) 

Pause animation.

void JAnimator::Resume (  ) 

Resume animation.

void JAnimator::Update ( float  dt  ) 

Update animation.

Parameters:
dt - Time elapsed since last update (in second).

void JAnimator::Render (  ) 

Render animation.

bool JAnimator::IsAnimating (  ) 

Check if animation is playing or not.

Returns:
True if playing animation.

bool JAnimator::IsActive (  ) 

Check if the animation is active.

Returns:
True if active.

void JAnimator::SetCurrentFrameIndex ( int  index  ) 

Set current frame to a particular index.

Parameters:
index - The new index of current frame.

int JAnimator::GetCurrentFrameIndex (  ) 

Get index of current frame.

Returns:
Index of current frame.

void JAnimator::SetAnimationType ( int  type  ) 

Set animation type.

Parameters:
type - Animation type.

void JAnimator::SetPosition ( float  x,
float  y 
)

Set position of the sprite.

Parameters:
x - X position.
y - Y position.

void JAnimator::SetHotSpot ( float  x,
float  y 
)

Set anchor point of the animation. All rendering operations will be based on this anchor point.

Parameters:
x - X position of the anchor point.
y - Y position of the anchor point.


Generated on Mon Oct 22 00:28:22 2007 for JGE++ by  doxygen 1.5.3