diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-11-19 21:24:36 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-11-19 21:24:36 +0000 |
commit | 7ac7d0e030464f744546b4e6183a7242f640d5d3 (patch) | |
tree | f19831b29511d46e8aba45ace6017c8e6afe815b /src/animation.h | |
parent | b7cfcffd7a156e19dfa9882d67426f4fa6edef57 (diff) | |
download | mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.tar.gz mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.tar.bz2 mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.tar.xz mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.zip |
Separated sprite definition from playback.
Diffstat (limited to 'src/animation.h')
-rw-r--r-- | src/animation.h | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/animation.h b/src/animation.h index 0230e820..85e950d7 100644 --- a/src/animation.h +++ b/src/animation.h @@ -24,8 +24,7 @@ #ifndef _TMW_ANIMATION_H #define _TMW_ANIMATION_H -#include <list> -#include <map> +#include <vector> #include <libxml/tree.h> @@ -34,6 +33,8 @@ class Spriteset; /** * A single frame in an animation, with a delay and an offset. + * + * TODO: Rename this struct to Frame */ struct AnimationPhase { @@ -56,12 +57,6 @@ class Animation Animation(); /** - * Restarts the animation from the first frame. - */ - void - reset(); - - /** * Appends a new animation at the end of the sequence */ void @@ -69,46 +64,38 @@ class Animation /** * Appends an animation terminator that states that the animation - * should not loop + * should not loop. */ void addTerminator(); /** - * Updates animation phase. - * true indicates a still running animation while false indicates a - * finished animation + * Returns the frame at the specified index. */ - bool - update(unsigned int time); - - const AnimationPhase* - getCurrentPhase() const; + AnimationPhase* + getFrame(int index) { return &(mAnimationPhases[index]); } /** - * Returns the x offset of the current frame. + * Returns the length of this animation in frames. */ - int - getOffsetX() const { return iCurrentPhase->offsetX; }; + unsigned int + getLength() const { return mAnimationPhases.size(); } /** - * Returns the y offset of the current frame. + * Returns the duration of this animation. */ int - getOffsetY() const { return iCurrentPhase->offsetY; }; + getDuration() const { return mDuration; } /** - * Returns the length of this animation. + * Determines whether the given animation frame is a terminator. */ - int - getLength() const { return mLength; } + static bool + isTerminator(const AnimationPhase phase); protected: - static bool isTerminator(AnimationPhase phase); - std::list<AnimationPhase> mAnimationPhases; - std::list<AnimationPhase>::iterator iCurrentPhase; - unsigned int mTime; - int mLength; + std::vector<AnimationPhase> mAnimationPhases; + int mDuration; }; #endif |