Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

Animation Class Reference

Animation is responsible to return the correct frame of an animation. More...

#include <animation.h>

Collaboration diagram for Animation:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Animation (const Image &abase_image, Uint16 aframes=1, BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, double afps=0, Uint16 astart_pos=0, AllignType aallign_type=AT_MD)
 Initialize the animation.
virtual void setBasePos (SDL_Rect *abase_pos)
 Set the base position of the animation.
virtual void unsetBasePos ()
 Unsets the base position of the animation.
virtual void runAnim ()
 Start the animation from the beginning (used when the animation was still).
virtual bool updateAnim (Uint16 dt)
virtual Frame getFrame () const
 Calculates and returns the current frame.
virtual SDL_Rect getDrawPos () const
virtual SDL_Rect getFrameDim () const
 HACK: Return the dimensions of the first frame.
virtual Frame getBaseFrame () const
 HACK: Return the base frame.
virtual bool isValid () const
 return True if the animation is valid
virtual bool isRunning () const
 return True if the animation is running
virtual bool isImage () const
 return True if the animation is a still image
virtual bool isFixed () const
 return True if the animation dimensions stay the same
virtual void setFallBack (EmptyAnimationPtr *)

Protected Member Functions

void setShift ()
 Helper function to set the shift values of the animation.
bool stopAnim ()
 Helper function to stop an animation.
bool checkAnim ()
 check validity of the animation

Protected Attributes

Image base_image
 Base image for the animation (big).
Uint16 frames
 Number of frames.
BasePointType bp_type
 The base point of the animation.
Uint16 animation_type
double fps
 FPS of the animation.
Uint16 start_pos
 Start position from the frame array of the base_image.
AllignType allign_type
 Allignment of the base point onto the base_pos.
SDL_Rect * base_pos
 Pointer to the current base position of the animation.
Sint16 shift_x
 shift is added as an additional value to the designated BP position.
Sint16 shift_y
Uint32 duration
 Duration of the animation in ms.
Uint16 base_frame_pos
 Position of the base frame.
Uint16 end_pos
 End position from the frame array of the base_image.
bool is_image
 True if the animation consist of one still image (frames=1,still=true).
bool is_valid
 True if the sanity checks suceeded.
bool is_fixed
 True if the image dimensions stay fixed during the whole animation (unused).
bool is_running
 True if the animation is running.
bool forward
 True if the animation is running forward at the moment.
Uint16 cur_frame_num
 Current frame number.
Uint32 cur_time
 Current time.

Detailed Description

Animation is responsible to return the correct frame of an animation.


Constructor & Destructor Documentation

Animation::Animation const Image abase_image,
Uint16  aframes = 1,
BasePointType  abp_type = BP_MD,
Uint16  aanimation_type = ATYPE_LOOP,
double  afps = 0,
Uint16  astart_pos = 0,
AllignType  aallign_type = AT_MD
 

Initialize the animation.

Parameters:
abase_image Base image used for the animation
aframes Number of frames
abp_type Base point type
aanimation_type Animation type
afps FPS of the animation, if (afps < 0) it is considered to be the duration in ms, if (afps==0) a default duration DATA_LVLDUR is taken
astart_pos Start position from the frame array of the base_image
aallign_type Allignment type
To load one still image simply use: Animation(imgcache->loadImage(1,"image_name.png"))


Member Function Documentation

virtual bool Animation::updateAnim Uint16  dt  )  [virtual]
 

Updates a running animation and stops it if necessary return True if the animation is still running

virtual SDL_Rect Animation::getDrawPos  )  const [virtual]
 

Calculates and returns the current draw position using: base_pos,bp_type,allign_type


Member Data Documentation

BasePointType Animation::bp_type [protected]
 

The base point of the animation.

The base point always stays fixed during the animation. It's types are: BP_xy, where x may be either L,M or R and y may be either U, M or D. L: left end, M: middle, R: right end, U: upper end, D: lower end

Example: BP_MU means the BP is the upper middle point of each frame. Default: BP_MD

Uint16 Animation::animation_type [protected]
 

Animation type: ATYPE_ONCE (play once), ATYPE_LOOP (always play, jump back to the beginning), ATYPE_SWING (always play, reverse direction when finnished), ATYPE_ST_SWITCH (parameter for ATYPE_ALL_ONCE: switch state when finnished). The appended _REV means that the animation is started at the end and played backwards.

AllignType Animation::allign_type [protected]
 

Allignment of the base point onto the base_pos.

The allignment specifies how the base point should be positioned wrt to the base_pos: It's type are basically the same as in BasePointType.

Example: (Assuming BP_MD) AT_LD means the middle point of each frame (BP_MD) is stays fixed wrt to the base position and the animation is placed with a "south west gravity" (similar to ImageMagick) wrt to the base position Default: AT_MD


The documentation for this class was generated from the following file:
Generated on Sun Feb 5 13:02:35 2006 for Lost Penguins by doxygen 1.3.8