41 IResource(createUniqueAnimationName(), loader),
43 m_animation_endtime(-1),
74 std::vector<FrameInfo>::iterator it =
m_frames.begin();
93 static std::string baseName =
"animation";
95 std::ostringstream oss;
96 oss << uniqueNumber <<
"_" << baseName;
98 const std::string name = oss.str();
111 std::map<uint32_t, FrameInfo>::const_iterator i(
m_framemap.end());
117 uint32_t frametime = i->first + i->second.duration;
127 std::map<uint32_t, FrameInfo>::const_iterator i(
m_framemap.upper_bound(timestamp));
129 val = i->second.index;
136 return size > 0 && index >= 0 && index < size;
153 std::map<uint32_t, FrameInfo>::const_iterator i(
m_framemap.upper_bound(timestamp));
155 val = i->second.image;
164 std::vector<ImagePtr> frames;
165 for (std::vector<FrameInfo>::iterator it =
m_frames.begin(); it !=
m_frames.end(); ++it) {
166 frames.push_back((*it).image);
virtual ResourceState getState()
virtual void load(IResource *res)
std::vector< ImagePtr > getFrames()
Gets all frame images.
void setDirection(uint32_t direction)
Animation direction tells how this animation is associated with movement when played starting from fr...
IResourceLoader * m_loader
int32_t m_animation_endtime
Animation(IResourceLoader *loader=0)
Constructor.
Contains information about one animation frame (duration + frame index + frame pointer) ...
ImagePtr getFrameByTimestamp(uint32_t timestamp)
Gets the frame image that matches the given timestamp.
std::vector< FrameInfo > m_frames
std::string createUniqueAnimationName()
int32_t getFrameIndex(uint32_t timestamp)
Get the frame index that matches given timestamp.
bool isValidIndex(int32_t index) const
Checks for animation frame index overflows.
std::map< uint32_t, FrameInfo > m_framemap
ImagePtr getFrame(int32_t index)
Gets the frame iamge that matches the given index.
void addFrame(ImagePtr image, uint32_t duration)
Adds new frame into animation Frames must be added starting from first frame.
uint32_t getFrameCount() const
Get the number of frames.
virtual void load(IResource *resource)=0
int32_t getFrameDuration(int32_t index) const
Gets the frame duration for given (indexed) frame.