public:
Animation()
- : sprite(0), frameTime(0), repeat(false) { }
+ : sprite(0), frameTime(0), colOffset(0), rowOffset(0), repeat(false) { }
Animation(const Sprite *sprite, int frameTime, bool repeat = false)
- : sprite(sprite), frameTime(frameTime), repeat(repeat) { }
+ : sprite(sprite), frameTime(frameTime), colOffset(0), rowOffset(0), repeat(repeat) { }
virtual ~Animation() { };
public:
bool Running() const {
return timer.Running() && (repeat || timer.Iteration() < NumFrames());
}
+
+ void SetColOffset(int offset) { colOffset = offset; }
+ int ColOffset() const { return colOffset; }
+ void SetRowOffset(int offset) { rowOffset = offset; }
+ int RowOffset() const { return rowOffset; }
+
virtual void Draw(SDL_Surface *dest, geometry::Point<int> position) const {
- sprite->Draw(dest, position, Col(), Row());
+ sprite->Draw(dest, position, Col() + ColOffset(), Row() + RowOffset());
}
void DrawTopRight(SDL_Surface *dest, geometry::Point<int> position) const {
geometry::Vector<int> offset(-sprite->Width(), 0);
const Sprite *sprite;
app::Timer<Uint32> timer;
int frameTime;
+ int colOffset;
+ int rowOffset;
bool repeat;
};