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;
}
}
-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<int> 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<int> &disposition)
: col(col), row(row), disposition(disposition) {}
int col;
int row;
geometry::Vector<int> 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<int> Offset(int frame) const { return frames[frame].disposition; }
+
+private:
std::vector<FrameProp> frames;
};
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; }