00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KYRA_SPRITE_INCLUDED
00033 #define KYRA_SPRITE_INCLUDED
00034
00035 #include "image.h"
00036 #include "spriteresource.h"
00037
00038
00061 class KrSprite : public KrImage
00062 {
00063 public:
00064 KrSprite( KrSpriteResource* resource );
00065 virtual ~KrSprite() {}
00066
00068 void SetFrame( int i );
00069
00071 void SetAction( const std::string& actionName );
00072
00083 void SetActionRotated( const std::string& actionName, int rotation );
00084
00088 void SetAction( U32 id );
00089
00091 KrAction* GetAction() { return action; }
00093 std::string ActionName() const { return action->Name(); }
00094
00096 int NumFrames() const { return action->NumFrames(); }
00098 int Frame() const { return frame; }
00100 KrRle* GetFrame() const { return action->GetFrame( frame ); };
00101
00106 void DoStep();
00107
00109 grinliz::Vector2I StepSize() const { return action->GetFrame( frame )->StepSize(); }
00110
00112 grinliz::Vector2I Stride();
00113
00114 virtual void QueryBoundingBox( grinliz::Rectangle2I* boundingBox, int window = 0 );
00115
00117 KrSpriteResource* SpriteResource() { return resource; }
00118 virtual KrResource* Resource() { return resource; }
00119
00120
00121 virtual bool HitTest( int x, int y, int flags, std::vector<KrImage*>* results, int window );
00122 virtual KrImNode* Clone();
00123
00124
00125
00126 virtual void Draw( KrPaintInfo* paintInfo,
00127 const grinliz::Rectangle2I& clip,
00128 int window );
00129
00130 virtual KrSprite* ToSprite() { return this; }
00131 virtual void CalcTransform( int win );
00132
00133 private:
00134 KrSprite();
00135 KrSprite& operator=( const KrSprite& );
00136
00137 KrAction* action;
00138 KrSpriteResource* resource;
00139 int frame;
00140 };
00141
00142
00143 #endif