Add Alot
This commit is contained in:
@@ -5,20 +5,20 @@
|
||||
|
||||
#include "utils.h"
|
||||
Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames),
|
||||
m_isLooping(isLooping), m_FrameDuration(frameDuration) {
|
||||
m_IsLooping(isLooping), m_FrameDuration(frameDuration) {
|
||||
|
||||
}
|
||||
void Animation::Update(float elapsedSec) {
|
||||
if (m_isPlaying) {
|
||||
if (m_IsPlaying) {
|
||||
m_FrameTimer -= elapsedSec;
|
||||
if (m_FrameTimer <= 0.0f) {
|
||||
m_FrameTimer = m_FrameDuration;
|
||||
++m_CurrentFrame;
|
||||
if (m_CurrentFrame >= m_Frames) {
|
||||
m_CurrentFrame = 0;
|
||||
if (!m_isLooping) {
|
||||
m_hasPlayedOnce = true;
|
||||
m_isPlaying = false;
|
||||
if (!m_IsLooping) {
|
||||
m_HasPlayedOnce = true;
|
||||
m_IsPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,22 +32,22 @@ void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
|
||||
Rectf src = m_SrcRect;
|
||||
src.left += static_cast<float>(m_CurrentFrame) * src.width;
|
||||
|
||||
m_pTexture->Draw(dst, src, m_isFlipped);
|
||||
m_pTexture->Draw(dst, src, m_IsFlipped);
|
||||
}
|
||||
void Animation::SetPlaying(bool isPlaying) {
|
||||
m_isPlaying = isPlaying;
|
||||
m_IsPlaying = isPlaying;
|
||||
}
|
||||
void Animation::SetFlipped(bool isFlipped) {
|
||||
m_isFlipped = isFlipped;
|
||||
m_IsFlipped = isFlipped;
|
||||
}
|
||||
void Animation::Reset() {
|
||||
m_CurrentFrame = 0;
|
||||
m_hasPlayedOnce = false;
|
||||
m_isPlaying = true;
|
||||
m_HasPlayedOnce = false;
|
||||
m_IsPlaying = true;
|
||||
m_FrameTimer = m_FrameDuration;
|
||||
}
|
||||
bool Animation::IsDone() const {
|
||||
return m_hasPlayedOnce && !m_isLooping;
|
||||
return m_HasPlayedOnce && !m_IsLooping;
|
||||
}
|
||||
int Animation::GetFrameCount() const {
|
||||
return m_Frames;
|
||||
|
||||
Reference in New Issue
Block a user