From bb7326004878abeadbe171db75d2caa0eae74431 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 28 Aug 2012 22:09:37 +0200 Subject: [PATCH] added setters for animations --- src/graphics/Animation.h | 6 +++++- src/graphics/ComplexAnimation.h | 18 +++++++++++------- src/graphics/SimpleAnimation.h | 5 +++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index 208f6bd..2696694 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -28,11 +28,15 @@ public: virtual ~Animation() { }; public: - const Sprite *GetSprite() const { return sprite; } int FrameTime() const { return frameTime; } bool Repeat() const { return repeat; } +public: + void SetSprite(const Sprite *s) { sprite = s; } + void SetFrameTime(int t) { frameTime = t; } + void SetRepeat(bool r) { repeat = r; } + public: virtual int NumFrames() const = 0; virtual int Col(int frame) const = 0; diff --git a/src/graphics/ComplexAnimation.h b/src/graphics/ComplexAnimation.h index 2eeea94..815e9c5 100644 --- a/src/graphics/ComplexAnimation.h +++ b/src/graphics/ComplexAnimation.h @@ -32,20 +32,24 @@ public: } } -protected: - virtual int NumFrames() const { return frames.size(); }; - virtual int Col(int frame) const { return frames[frame].col; } - virtual int Row(int frame) const { return frames[frame].row; } - virtual geometry::Vector Offset(int frame) const { return frames[frame].disposition; } - -private: +public: struct FrameProp { + FrameProp() : col(0), row(0) { } FrameProp(int col, int row, const geometry::Vector &disposition) : col(col), row(row), disposition(disposition) {} int col; int row; geometry::Vector disposition; }; + void AddFrame(const FrameProp &f) { frames.push_back(f); } + +protected: + virtual int NumFrames() const { return frames.size(); }; + virtual int Col(int frame) const { return frames[frame].col; } + virtual int Row(int frame) const { return frames[frame].row; } + virtual geometry::Vector Offset(int frame) const { return frames[frame].disposition; } + +private: std::vector frames; }; diff --git a/src/graphics/SimpleAnimation.h b/src/graphics/SimpleAnimation.h index d15c1d9..003a031 100644 --- a/src/graphics/SimpleAnimation.h +++ b/src/graphics/SimpleAnimation.h @@ -21,6 +21,11 @@ public: SimpleAnimation(const Sprite *sprite, int frameTime, int numFrames, int col = 0, int row = 0, bool repeat = false) : Animation(sprite, frameTime, repeat), numFrames(numFrames), col(col), row(row) { } +public: + void SetNumFrames(int n) { numFrames = n; } + void SetCol(int c) { col = c; } + void SetRow(int r) { row = r; } + protected: virtual int NumFrames() const { return numFrames; }; virtual int Col(int frame) const { return col; } -- 2.39.2