From: Daniel Karbach Date: Tue, 2 Oct 2012 20:25:17 +0000 (+0200) Subject: frame shiftability in animation runner X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;ds=inline;h=be7ebd20e65d42e96c43a81f73039beded2c05e7;p=l2e.git frame shiftability in animation runner --- diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index 4442f89..7424918 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -60,7 +60,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 +90,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 +118,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;