Sprite Class Reference

General clss representing a sprite. More...

#include <sprite.h>

List of all members.

Public Member Functions

 Sprite ()
 Default constructor.
void toggleLoop (bool b)
 Flag whether or not this sprite should loop the animations.
bool loop ()
 See if looping is enabled.
bool done ()
 See if this sprite has finished playing.
void setAnimation (const ustring &anim)
 Set the animation to play.
void animate (int x, int y, SDL_Surface *dest=SDL_GetVideoSurface())
 Animate the sprite.
void renderFrame (const Point &p, int frame=0)
 Render a single frame of current animation.
void addAnimation (const Animation &anim)
 Add an entire animation to the sprite.
ustring getCurrentAnimationId () const
 Get the ID of the current animation.
AnimationgetAnimation (const ustring &id)
 Get an animation sequence.
AnimationMap getAnimations () const
 Get the full map of animations.
FramegetCurrentFrame ()
 Get the current frame.
int numAnimations () const
 Get the amount of animations in this sprite.
void addFrame (const ustring &id, int time, SDL_Surface *frame)
 Add a frame to an animation sequence.
void reset ()
 Reset the sprite.

Private Attributes

ustring m_CurAnim
int m_CurFrame
int m_LastFrame
AnimationMap m_Animations
 Internal map of animations.


Detailed Description

General clss representing a sprite.

The Sprite class stores all of the image data needed to function. It also keeps track of the current frame of animation, as well as management of many animations. In addition, it provides the utility to create animations from a series of GIF files. Besides just storing data, the Sprite class is also in charge of playing the actual animations, including correctly timing each frame.


Member Function Documentation

void Sprite::toggleLoop ( bool  b  ) 

Flag whether or not this sprite should loop the animations.

Parameters:
b true to enable, false to disable

bool Sprite::loop (  ) 

See if looping is enabled.

Returns:
true if enabled, false otherwise

bool Sprite::done (  ) 

See if this sprite has finished playing.

Returns:
true if done, false otherwise

void Sprite::setAnimation ( const ustring &  anim  ) 

Set the animation to play.

Parameters:
anim The ID of the animation

void Sprite::animate ( int  x,
int  y,
SDL_Surface *  dest = SDL_GetVideoSurface() 
)

Animate the sprite.

Parameters:
x The x-coordinate where to draw the sprite
y The y-coordinate where to draw the sprite
dest The destination surface

void Sprite::renderFrame ( const Point p,
int  frame = 0 
)

Render a single frame of current animation.

Parameters:
p The point where to draw
frame The frame to draw

void Sprite::addAnimation ( const Animation anim  )  [inline]

Add an entire animation to the sprite.

Parameters:
anim The animation to add

ustring Sprite::getCurrentAnimationId (  )  const [inline]

Get the ID of the current animation.

Returns:
The current animation's ID

Animation * Sprite::getAnimation ( const ustring &  id  ) 

Get an animation sequence.

Parameters:
id The ID of the animation
Returns:
Pointer to requested Animation struct

AnimationMap Sprite::getAnimations (  )  const [inline]

Get the full map of animations.

Returns:
All of the animations in the sprite

Frame * Sprite::getCurrentFrame (  ) 

Get the current frame.

Returns:
Pointer to the current frame

int Sprite::numAnimations (  )  const [inline]

Get the amount of animations in this sprite.

Returns:
The amount of animations in the sprite

void Sprite::addFrame ( const ustring &  id,
int  time,
SDL_Surface *  frame 
)

Add a frame to an animation sequence.

Parameters:
id The ID of the target animation
time The time duration of the frame
frame The frame image


The documentation for this class was generated from the following files:
Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3