Main Page   Class Hierarchy   Compound List   File List   Compound Members  

KrSprite Class Reference

The most obvious class for a sprite image, describes on on screen image, potentially with multiple actions and frames. More...

#include <sprite.h>

Inheritance diagram for KrSprite::

KrImage KrImNode List of all members.

Public Methods

void SetFrame (int i)
 Set the current frame for the current action.

void SetAction (const std::string &actionName)
 Set the current action by its name. "STANDING".

void SetActionRotated (const std::string &actionName, int rotation)
 [Experimental, added 1.6] Rotations applied by the encoder change the action name to reflect the rotation. More...

void SetAction (U32 id)
 Note this is the action Id (written by the encoder: STANDING), NOT the index (whatever that happens to be.

KrActionGetAction ()
 Get a pointer to the current action.

std::string ActionName () const
 Get the name of the current action.

int NumFrames () const
 Return the number of frames in the current action.

int Frame () const
 Return the current frame of the current action.

void DoStep ()
 Take one step: advance the frame and move the position of the sprite. More...

KrVector2 Stride ()
 Get the sum of distance covered by all the DoSteps.

virtual void QueryBoundingBox (KrRect *boundingBox, int window=0)
 Get the bounding box of the image, in its current state. More...

KrSpriteResourceSpriteResource ()
 Get the resource for this Sprite.

virtual bool HitTest (int x, int y, int flags, GlDynArray< KrImage *> *results, int window)
 Hit test this object. Returns true if there was a hit, and 'this' will be added to results.

virtual KrImNodeClone ()
 Return a copy if this object, not in a Tree(). More...

virtual KrSprite * ToSprite ()
 Return a pointer if this is a sprite.


Detailed Description

The most obvious class for a sprite image, describes on on screen image, potentially with multiple actions and frames.

Almost all pre-generated images are sprites. The only reason to use a tile is for rotation.

A Sprite contains an arbitrary number of actions, each of which has any number of frames.

        An example:
                Sprite: "DRONE", an alien creature
                        Action: "WALK.DIR7", walking NW
                                Frames: 0, 1, 2, 3, 4, 5
                        Action: "WALK.DIR9", walking NE
                                Frames: 0, 1, 2, 3, 4, 5
                        Action: "STANDING", no motion
                                Frames: 0

        


Member Function Documentation

virtual KrImNode* KrSprite::Clone   [virtual]
 

Return a copy if this object, not in a Tree().

It is return untransformed. In the case of a sprite, the action and frame will be set to the current value.

Reimplemented from KrImNode.

void KrSprite::DoStep  
 

Take one step: advance the frame and move the position of the sprite.

Not all sprites have steps. They are configured in the Sprite editor.

virtual void KrSprite::QueryBoundingBox KrRect   boundingBox,
int    window = 0
[virtual]
 

Get the bounding box of the image, in its current state.

If this is a sprite, it will be the bounding box of the current frame and action. The bounds are relative to the hotspot, so xmin and ymin will often be not zero.

The current transformation matrix will be applied, so the result may be transformed bounds.

Reimplemented from KrImage.

void KrSprite::SetActionRotated const std::string &    actionName,
int    rotation
 

[Experimental, added 1.6] Rotations applied by the encoder change the action name to reflect the rotation.

ROT000, where 000 is the rotation, in integer degrees. It as appended as the last segment of the name. For instance,

"STANDING.ROT090" and STANDING | ROT090

would be the string and integer representations. This method, giving the leading string ("STANDING") will add the rotation automatically.


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 12:01:11 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001