21 m_secondsPerFrame = 0.6f;
22 m_currentFrameTime = m_secondsPerFrame;
31 std::vector<Region *>::iterator it;
32 for (it = m_frames.begin(); it != m_frames.end(); ++it)
46 if (m_currentFrameTime <= 0)
49 m_currentFrameTime = m_secondsPerFrame;
51 if (m_currentIndex == m_frames.size())
53 if (m_loopCounter > 0) m_loopCounter--;
54 else if (m_loopCounter == 0)
Stop();
55 else m_currentIndex = 0;
64 std::ifstream fileIn(path.c_str(), std::ifstream::in);
66 if (fileIn.is_open() && fileIn.good())
69 std::vector<std::string> splitElements;
71 bool loadingSpriteSheet =
true;
72 bool loadingFrameTime =
true;
74 while (getline(fileIn, line))
77 if (line.empty())
continue;
79 if (loadingSpriteSheet)
82 loadingSpriteSheet =
false;
84 else if (loadingFrameTime)
86 m_secondsPerFrame = atof(line.c_str());
87 loadingFrameTime =
false;
91 Split(line,
',', splitElements);
94 frame->
X = atoi(splitElements[0].c_str());
95 frame->
Y = atoi(splitElements[1].c_str());
96 frame->
Width = atoi(splitElements[2].c_str());
97 frame->
Height = atoi(splitElements[3].c_str());
98 m_frames.push_back(frame);
115 if (index < m_frames.size())
117 m_currentIndex = index;
118 m_currentFrameTime = m_secondsPerFrame;
133 clone->m_pTexture = m_pTexture;
134 clone->m_frames = m_frames;
135 clone->m_secondsPerFrame = m_secondsPerFrame;
136 clone->m_isPlaying = m_isPlaying;
137 clone->m_currentFrameTime = m_currentFrameTime;
138 clone->m_currentIndex = m_currentIndex;
Represents timing and framing values for texture animations.
virtual void SetCurrentFrame(const unsigned int index)
Sets the current frame of the animation.
virtual void Pause()
Pauses the animation.
virtual void Update(const GameTime &gameTime)
Updates the animation.
virtual Resource * Clone()
Used to create a clone of the animation.
virtual bool Load(const std::string &path, ResourceManager *pManager)
Load the desired animation into memory.
virtual void Stop()
Stops the animation.
Contains timing values for game updates and rendering.
double GetElapsedTime() const
Gets the time in seconds since last frame.
Defines a rectangular region defined by a point, height, width.
int X
The left side of the region.
int Height
The height of the region.
int Y
The top of the region.
int Width
The width of the region.
Base class for all resource types to be managed by the ResourceManager class.
void Split(const std::string &line, const char delimeter, std::vector< std::string > &elements)
Splits a string into a vector of strings.
void ParseComments(std::string &line)
Removes c-style, single-line comments from a line of text.
Loads and manages the lifespan of objects from external files.
T * Load(const std::string &path, const bool cache=true, const bool appendContentPath=true)
Load and manage a resource.
Represents a 2D grid of texels.
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...