00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VIDEO_ANIMATION_H
00023 #define FIFE_VIDEO_ANIMATION_H
00024
00025
00026 #include <cassert>
00027 #include <map>
00028 #include <vector>
00029
00030
00031 #include "util/base/fife_stdint.h"
00032
00033
00034
00035
00036
00037
00038
00039 #include "util/base/resourceclass.h"
00040 #include "util/resource/resource_ptr.h"
00041
00042 namespace FIFE {
00043
00044 class Image;
00045
00054 class Animation : public ResourceClass {
00055 public:
00058 explicit Animation();
00059
00062 ~Animation();
00063
00070 void addFrame(ResourcePtr image, unsigned int duration);
00071
00078 int getFrameIndex(unsigned int timestamp);
00079
00082 Image* getFrame(int index);
00083
00086 Image* getFrameByTimestamp(unsigned int timestamp);
00087
00091 int getFrameDuration(int index) const;
00092
00095 unsigned int getNumFrames() const;
00096
00103 void setActionFrame(int num) { m_action_frame = num; }
00104
00108 int getActionFrame() const { return m_action_frame; }
00109
00117 void setDirection(unsigned int direction);
00118
00123 unsigned int getDirection() const { return m_direction; }
00124
00127 unsigned int getDuration() const { return m_animation_endtime; }
00128
00129 private:
00132 struct FrameInfo {
00133 unsigned int index;
00134 unsigned int duration;
00135 ResourcePtr image;
00136 };
00137
00140 bool isValidIndex(int index) const;
00141
00142
00143 std::map<unsigned int, FrameInfo> m_framemap;
00144
00145 std::vector<FrameInfo> m_frames;
00146
00147 int m_action_frame;
00148
00149 int m_animation_endtime;
00150
00151 unsigned int m_direction;
00152
00153 };
00154 }
00155
00156 #endif
00157