X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FAnimation.h;h=50330957ab9d28412cb1314c70596f86d75ead1f;hb=5228f225de7e2c047d3ddf0b9edfc9a05c4ea167;hp=4442f89efddac88b3ecf7cb178cb219f01a50ca9;hpb=a67a3c4f6bc11cd5284d6c5aabf4a3e180517a03;p=l2e.git diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index 4442f89..5033095 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -1,10 +1,3 @@ -/* - * Animation.h - * - * Created on: Aug 11, 2012 - * Author: holy - */ - #ifndef GRAPHICS_ANIMATION_H_ #define GRAPHICS_ANIMATION_H_ @@ -22,6 +15,9 @@ namespace graphics { class Animation { +public: + static const int TYPE_ID = 401; + public: Animation() : sprite(0), frameTime(0), repeat(false) { } @@ -45,8 +41,10 @@ public: virtual int Row(int frame) const = 0; virtual geometry::Vector Offset(int frame) const { return geometry::Vector(); } + static void CreateTypeDescription(); + protected: - static void AddFields(loader::TypeDescription &, const Animation &, std::ptrdiff_t offset, int boolId, int numberId, int spriteId); + static void AddFields(loader::TypeDescription &, const Animation &, std::ptrdiff_t offset); private: const Sprite *sprite; @@ -60,7 +58,7 @@ class AnimationRunner { public: explicit AnimationRunner(const Animation *a = 0, int colOffset = 0, int rowOffset = 0) - : animation(a), sprite(0), colOffset(colOffset), rowOffset(rowOffset) { } + : animation(a), sprite(0), frameShift(0), colOffset(colOffset), rowOffset(rowOffset) { } public: bool Valid() const { return animation; } @@ -90,6 +88,8 @@ public: const app::Timer &GetTimer() { return timer; } + void SetFrameShift(int offset) { frameShift = offset; } + int FrameShift() const { return frameShift; } void SetColOffset(int offset) { colOffset = offset; } int ColOffset() const { return colOffset; } void SetRowOffset(int offset) { rowOffset = offset; } @@ -116,12 +116,13 @@ public: Draw(dest, position + offset); } - int Frame() const { return Running() ? (timer.Iteration() % animation->NumFrames()) : 0; } + int Frame() const { return Running() ? ((timer.Iteration() + frameShift) % animation->NumFrames()) : 0; } private: const Animation *animation; const graphics::Sprite *sprite; app::Timer timer; + int frameShift; int colOffset; int rowOffset;