hoa_video::AnimatedImage Class Reference

Represents an animated image with both frames and timing information. More...

#include <image.h>

Inheritance diagram for hoa_video::AnimatedImage:

Inheritance graph
[legend]
Collaboration diagram for hoa_video::AnimatedImage:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool AddFrame (const std::string &frame, uint32 frame_time)
 Adds an animation frame using the filename of the image to add.
bool AddFrame (const StillImage &frame, uint32 frame_time)
 Adds an animation frame by using an existing static image.
 AnimatedImage (const bool grayscale=false)
void Clear ()
 Removes the data and properties allocated to the animated image.
void DisableGrayScale ()
 Disables grayscale for the image.
void EnableGrayScale ()
 Enables grayscale for the image.
void ResetAnimation ()
 Resets the animation's frame, counter, and looping.
void Update ()
 Called every frame to update the animation's current frame. This will automatically synchronize the animation to VIDEO_ANIMATION_FRAME_PERIOD, i.e. 30 frames per second. If you want to update the frames yourself using some custom method, then use SetFrame().
Class Member Get Functions
uint32 GetCurrentFrameIndex () const
 Returns the index number of the current frame in the animation.
StillImageGetFrame (uint32 index) const
 Returns a pointer to the StillImage at a specified frame.
float GetHeight () const
 Returns the height of the 1st frame of animation.
uint32 GetNumFrames () const
 Returns the number of frames in this animation.
float GetPercentProgress () const
 Returns the percentage of timing complete for the current frame being shown.
uint32 GetTimeProgress () const
 Returns the number of milliseconds that the current frame has been shown for.
float GetWidth () const
 Returns the width of the 1st frame of animation.
bool IsLoopsFinished () const
 Returns true if the loops have finished, false otherwise.
Class Member Set Functions
void SetColor (const Color &color)
 sets All frames to be of a certain color (all vertices are set to the same color)
void SetDimensions (const float width, const float height)
 Sets all animation frames to be a certain width and height.
void SetFrameIndex (const uint32 index)
 Sets the current frame index of the animation.
void SetHeight (const float height)
 Sets all animation frames to be a certain height.
void SetLoopCounter (int32 loops)
 Set the current number of loops that the animation has completed.
void SetLoopsFinished (bool loops)
 Effectively stops the animation in its track if this member is set to true.
void SetNumberLoops (int32 loops)
 Set the number of loops for the animation. A value less than zero indicates to loop forever. Zero indicates do not loop: just run the animation from beginning to end and stop.
void SetStatic (const bool is_static)
 Sets the static member for all animation frame images.
void SetTimeProgress (uint32 time)
 Sets the number of milliseconds that the current frame has been shown for.
void SetVertexColors (const Color &tl, const Color &tr, const Color &bl, const Color &br)
 sets all frames to have the specified vertex colors
void SetWidth (const float width)
 Sets all animation frames to be a certain width.

Private Attributes

uint32 _frame_counter
 Counts how long each frame has been shown for.
uint32 _frame_index
 The index of which animation frame to display.
std::vector< private_video::AnimationFrame_frames
 The vector of animation frames (both frame images and frame timing).
int32 _loop_counter
 Counts the number of loops remaining for the animation.
bool _loops_finished
 Set to true when the loop counter has expired. This member will remain eternally false if the looping is set to infinite mode.
int32 _number_loops
 The number of times to loop the animation frames. A value less than zero indicates to loop forever, which is the default.

Friends

class GameVideo

Detailed Description

Represents an animated image with both frames and timing information.

****************************************************************************

Animated images are really nothing more than a series of individual still images and timing information for each frame. This class assumes that all frame images are the same size, so you should not attempt to use this class if your frames are of different sizes. If you wish to use different sized frame images in an animation, you'll need to implement the code to do so yourself.

Definition at line 485 of file image.h.


Constructor & Destructor Documentation

hoa_video::AnimatedImage::AnimatedImage ( const bool  grayscale = false  ) 

Definition at line 403 of file image.cpp.

References hoa_video::ImageDescriptor::_animated, hoa_video::ImageDescriptor::_grayscale, _loop_counter, _loops_finished, _number_loops, and Clear().

Here is the call graph for this function:


Member Function Documentation

bool hoa_video::AnimatedImage::AddFrame ( const std::string &  frame,
uint32  frame_time 
)

Adds an animation frame using the filename of the image to add.

Parameters:
frame The filename of the frame image to add.
frame_time The number of milliseconds that this animation should last for
Returns:
True on success, false on failure.
This is perhaps a more convenient way to add frames, but this makes it impossible to control the image properties such as vertex colors, and size. If you use this function, the width and height will be the pixel width/height of the image itself. This is not what you always will want. For example, if your coordinate system is in terms of 32x32 pixel tiles, then a tile image would have a width and height of 1, not 32.

Definition at line 481 of file image.cpp.

References hoa_video::ImageDescriptor::_color, _frames, hoa_video::ImageDescriptor::_height, hoa_video::ImageDescriptor::_is_static, hoa_video::ImageDescriptor::_width, hoa_video::private_video::AnimationFrame::frame_time, hoa_video::private_video::AnimationFrame::image, hoa_video::StillImage::SetDimensions(), hoa_video::StillImage::SetFilename(), hoa_video::StillImage::SetStatic(), and hoa_video::StillImage::SetVertexColors().

Here is the call graph for this function:

bool hoa_video::AnimatedImage::AddFrame ( const StillImage frame,
uint32  frame_time 
)

Adds an animation frame by using an existing static image.

Parameters:
frame The still image to use as the frame image.
frame_time The amount of millseconds to display the frame.
Returns:
True on success, false on failure.

Definition at line 498 of file image.cpp.

References hoa_video::StillImage::_elements, _frames, hoa_video::private_video::AnimationFrame::frame_time, and hoa_video::private_video::AnimationFrame::image.

Referenced by hoa_map::MapMode::_LoadTiles(), hoa_battle::BattleMode::BattleMode(), hoa_video::private_video::ParticleSystem::Create(), and hoa_global::GlobalCharacter::GlobalCharacter().

void hoa_video::AnimatedImage::Clear (  )  [virtual]

Removes the data and properties allocated to the animated image.

Implements hoa_video::ImageDescriptor.

Definition at line 414 of file image.cpp.

References hoa_video::ImageDescriptor::_Clear(), _frame_counter, _frame_index, _frames, _loop_counter, _loops_finished, _number_loops, SetColor(), and hoa_video::Color::white.

Referenced by AnimatedImage().

Here is the call graph for this function:

void hoa_video::AnimatedImage::DisableGrayScale (  ) 

Disables grayscale for the image.

Definition at line 439 of file image.cpp.

References _frames, hoa_video::StillImage::DisableGrayScale(), and GetFrame().

Here is the call graph for this function:

void hoa_video::AnimatedImage::EnableGrayScale (  ) 

Enables grayscale for the image.

Definition at line 428 of file image.cpp.

References _frames, hoa_video::StillImage::EnableGrayScale(), and GetFrame().

Here is the call graph for this function:

uint32 hoa_video::AnimatedImage::GetCurrentFrameIndex (  )  const [inline]

Returns the index number of the current frame in the animation.

Definition at line 620 of file image.h.

References _frame_index.

Referenced by hoa_video::private_video::ParticleSystem::Draw(), and hoa_video::GameVideo::DrawImage().

StillImage* hoa_video::AnimatedImage::GetFrame ( uint32  index  )  const [inline]

Returns a pointer to the StillImage at a specified frame.

Parameters:
index index of the frame you want
Returns:
A pointer to the image at that index
Using this function is dangerous since it provides direct access to an image frame. If you find yourself in constant need of using this function, think twice about what you are doing.

Definition at line 631 of file image.h.

References _frames.

Referenced by DisableGrayScale(), hoa_video::private_video::ParticleSystem::Draw(), hoa_video::GameVideo::DrawImage(), EnableGrayScale(), SetColor(), SetDimensions(), SetHeight(), SetVertexColors(), and SetWidth().

float hoa_video::AnimatedImage::GetHeight (  )  const [inline, virtual]

Returns the height of the 1st frame of animation.

Note:
Function will return 0.0f if there are no animation frames.

Implements hoa_video::ImageDescriptor.

Definition at line 612 of file image.h.

References _frames.

uint32 hoa_video::AnimatedImage::GetNumFrames (  )  const [inline]

Returns the number of frames in this animation.

Definition at line 616 of file image.h.

References _frames.

float hoa_video::AnimatedImage::GetPercentProgress (  )  const [inline]

Returns the percentage of timing complete for the current frame being shown.

Returns:
A float from 0.0f to 1.0f, indicate how much of its allotted time this frame has spent.

Definition at line 641 of file image.h.

References _frame_counter, _frame_index, and _frames.

Referenced by hoa_video::private_video::ParticleSystem::Draw().

uint32 hoa_video::AnimatedImage::GetTimeProgress (  )  const [inline]

Returns the number of milliseconds that the current frame has been shown for.

Definition at line 635 of file image.h.

References _frame_counter.

float hoa_video::AnimatedImage::GetWidth (  )  const [inline, virtual]

Returns the width of the 1st frame of animation.

Note:
Function will return 0.0f if there are no animation frames.

Implements hoa_video::ImageDescriptor.

Definition at line 607 of file image.h.

References _frames.

bool hoa_video::AnimatedImage::IsLoopsFinished (  )  const [inline]

Returns true if the loops have finished, false otherwise.

Definition at line 645 of file image.h.

References _loops_finished.

void hoa_video::AnimatedImage::ResetAnimation (  )  [inline]

Resets the animation's frame, counter, and looping.

Definition at line 507 of file image.h.

References _frame_counter, _frame_index, _loop_counter, and _loops_finished.

void hoa_video::AnimatedImage::SetColor ( const Color color  )  [virtual]

sets All frames to be of a certain color (all vertices are set to the same color)

Parameters:
color Color of the 4 vertices

Implements hoa_video::ImageDescriptor.

Definition at line 558 of file image.cpp.

References hoa_video::ImageDescriptor::_color, _frames, GetFrame(), and hoa_video::StillImage::SetColor().

Referenced by Clear().

Here is the call graph for this function:

void hoa_video::AnimatedImage::SetDimensions ( const float  width,
const float  height 
) [virtual]

Sets all animation frames to be a certain width and height.

Parameters:
width Width of the images
height Height of the images

Implements hoa_video::ImageDescriptor.

Definition at line 544 of file image.cpp.

References _frames, hoa_video::ImageDescriptor::_height, hoa_video::ImageDescriptor::_width, GetFrame(), and hoa_video::StillImage::SetDimensions().

Referenced by hoa_map::MapMode::_LoadTiles().

Here is the call graph for this function:

void hoa_video::AnimatedImage::SetFrameIndex ( const uint32  index  )  [inline]

Sets the current frame index of the animation.

Parameters:
index The index of the frame to access
Note:
Passing in an invalid value for the index will not change the current frame

Definition at line 573 of file image.h.

References _frame_counter, _frame_index, and _frames.

Referenced by hoa_global::GlobalCharacter::GlobalCharacter().

void hoa_video::AnimatedImage::SetHeight ( const float  height  )  [virtual]

Sets all animation frames to be a certain height.

Parameters:
height Height of the images

Implements hoa_video::ImageDescriptor.

Definition at line 531 of file image.cpp.

References _frames, hoa_video::ImageDescriptor::_height, GetFrame(), and hoa_video::StillImage::SetHeight().

Here is the call graph for this function:

void hoa_video::AnimatedImage::SetLoopCounter ( int32  loops  )  [inline]

Set the current number of loops that the animation has completed.

Parameters:
loops Current loop count

Definition at line 593 of file image.h.

References _loop_counter.

void hoa_video::AnimatedImage::SetLoopsFinished ( bool  loops  )  [inline]

Effectively stops the animation in its track if this member is set to true.

Parameters:
loops Flag for stoping the looping procecss

Definition at line 599 of file image.h.

References _loops_finished.

void hoa_video::AnimatedImage::SetNumberLoops ( int32  loops  )  [inline]

Set the number of loops for the animation. A value less than zero indicates to loop forever. Zero indicates do not loop: just run the animation from beginning to end and stop.

Parameters:
loops Number of loops for the animation

Definition at line 587 of file image.h.

References _number_loops.

void hoa_video::AnimatedImage::SetStatic ( const bool  is_static  )  [inline, virtual]

Sets the static member for all animation frame images.

Parameters:
is_static Flag indicating wether the image will be static or not.
Note:
If the frames are already loaded, it doesn't bother to try to unload them and then reload them again statically.

Implements hoa_video::ImageDescriptor.

Definition at line 566 of file image.h.

References hoa_video::ImageDescriptor::_is_static.

void hoa_video::AnimatedImage::SetTimeProgress ( uint32  time  )  [inline]

Sets the number of milliseconds that the current frame has been shown for.

Parameters:
time Time of the frame counter

Definition at line 579 of file image.h.

References _frame_counter.

void hoa_video::AnimatedImage::SetVertexColors ( const Color tl,
const Color tr,
const Color bl,
const Color br 
) [virtual]

sets all frames to have the specified vertex colors

Parameters:
tl The top left vertex color
tr The top right vertex color
bl The bottom left vertex color
br The bottom right vertex color

Implements hoa_video::ImageDescriptor.

Definition at line 575 of file image.cpp.

References hoa_video::ImageDescriptor::_color, _frames, GetFrame(), and hoa_video::StillImage::SetVertexColors().

Here is the call graph for this function:

void hoa_video::AnimatedImage::SetWidth ( const float  width  )  [virtual]

Sets all animation frames to be a certain width.

Parameters:
width Width of the images

Implements hoa_video::ImageDescriptor.

Definition at line 518 of file image.cpp.

References _frames, hoa_video::ImageDescriptor::_width, GetFrame(), and hoa_video::StillImage::SetWidth().

Here is the call graph for this function:

void hoa_video::AnimatedImage::Update (  ) 

Called every frame to update the animation's current frame. This will automatically synchronize the animation to VIDEO_ANIMATION_FRAME_PERIOD, i.e. 30 frames per second. If you want to update the frames yourself using some custom method, then use SetFrame().

Definition at line 450 of file image.cpp.

References _frame_counter, _frame_index, _frames, _loop_counter, _loops_finished, _number_loops, hoa_video::GameVideo::GetFrameChange(), and hoa_video::VideoManager.

Referenced by hoa_video::private_video::ParticleSystem::Update(), hoa_map::private_map::VirtualSprite::Update(), hoa_battle::private_battle::BattleCharacterActor::Update(), and hoa_battle::BattleMode::Update().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class GameVideo [friend]

Reimplemented from hoa_video::ImageDescriptor.

Definition at line 486 of file image.h.


Member Data Documentation

uint32 hoa_video::AnimatedImage::_frame_counter [private]

Counts how long each frame has been shown for.

Definition at line 654 of file image.h.

Referenced by Clear(), GetPercentProgress(), GetTimeProgress(), ResetAnimation(), SetFrameIndex(), SetTimeProgress(), and Update().

uint32 hoa_video::AnimatedImage::_frame_index [private]

The index of which animation frame to display.

Definition at line 651 of file image.h.

Referenced by Clear(), GetCurrentFrameIndex(), GetPercentProgress(), ResetAnimation(), SetFrameIndex(), and Update().

std::vector<private_video::AnimationFrame> hoa_video::AnimatedImage::_frames [private]

The vector of animation frames (both frame images and frame timing).

Definition at line 670 of file image.h.

Referenced by AddFrame(), Clear(), DisableGrayScale(), EnableGrayScale(), GetFrame(), GetHeight(), GetNumFrames(), GetPercentProgress(), GetWidth(), SetColor(), SetDimensions(), SetFrameIndex(), SetHeight(), SetVertexColors(), SetWidth(), and Update().

int32 hoa_video::AnimatedImage::_loop_counter [private]

Counts the number of loops remaining for the animation.

Definition at line 662 of file image.h.

Referenced by AnimatedImage(), Clear(), ResetAnimation(), SetLoopCounter(), and Update().

bool hoa_video::AnimatedImage::_loops_finished [private]

Set to true when the loop counter has expired. This member will remain eternally false if the looping is set to infinite mode.

Definition at line 667 of file image.h.

Referenced by AnimatedImage(), Clear(), IsLoopsFinished(), ResetAnimation(), SetLoopsFinished(), and Update().

int32 hoa_video::AnimatedImage::_number_loops [private]

The number of times to loop the animation frames. A value less than zero indicates to loop forever, which is the default.

Definition at line 659 of file image.h.

Referenced by AnimatedImage(), Clear(), SetNumberLoops(), and Update().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:16:13 2007 for Hero of Allacrost by  doxygen 1.5.1