00001 #ifndef __ANIMATEDSPRITE_H__
00002 #define __ANIMATEDSPRITE_H__
00003
00004 #ifndef DOXYGEN_IGNORE_TAG
00005
00026 #endif
00027
00028 #include <SDL/SDL.h>
00029
00030 #include <string>
00031
00032 #include "../Types/Vec2.h"
00033 #include "../Types/Size2.h"
00034 #include "../Types/Rect.h"
00035
00036 namespace NE { class Renderer; }
00037 namespace NE { class SpriteLoader; }
00038 namespace NE { class Sprite; }
00039
00040 struct Colour;
00041
00042 class AnimatedSprite
00043 {
00044 private:
00045
00046 NE::Sprite* pSprite;
00047
00048 USize2 spriteSize;
00049
00050 unsigned int numberAnimation;
00051 unsigned int animationCounter;
00053 unsigned int lastUpdate;
00055 unsigned int msInterval;
00057
00058 AnimatedSprite(const AnimatedSprite& as);
00059 void operator= (const AnimatedSprite& as);
00060
00061 void update(const unsigned int time);
00062
00063 public:
00064 AnimatedSprite(NE::Sprite* pSprite, const USize2& spriteSize, const unsigned int msInterval);
00065 AnimatedSprite(NE::SpriteLoader* pSL, const std::string& fileName, const USize2& spriteSize, const unsigned int msInterval);
00066
00067 ~AnimatedSprite(void);
00068
00069 Rect getSrcRect(const unsigned int time);
00070
00071 USize2 getSize(void)const { return spriteSize; }
00072
00073 unsigned int getInterval(void)const { return msInterval; }
00074 void setInterval(const unsigned int newInterval) { msInterval = newInterval; }
00075
00076 bool draw(const NE::Renderer& r, const IVec2& position, const unsigned int time=0);
00077 bool draw(const NE::Renderer& r, const IVec2& position, const Colour& mask, const unsigned int time=0);
00078 };
00079
00154 #endif