#include <sprite.h>
Inheritance diagram for KrSprite::
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. | |
KrAction * | GetAction () |
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... | |
KrSpriteResource * | SpriteResource () |
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 KrImNode * | Clone () |
Return a copy if this object, not in a Tree(). More... | |
virtual KrSprite * | ToSprite () |
Return a pointer if this is a sprite. |
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
|
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. |
|
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. |
|
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. |
|
[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. |