1#ifndef UTIL_ANIMATION_HPP
2#define UTIL_ANIMATION_HPP
8#include "Core/Drawable.hpp"
10#include "Util/Image.hpp"
38 Animation(
const std::vector<std::string> &paths,
bool play,
39 std::size_t interval,
bool looping =
true,
40 std::size_t cooldown = 100);
82 glm::vec2
GetSize()
const override {
return m_Frames[m_Index]->GetSize(); }
136 std::vector<std::shared_ptr<Util::Image>> m_Frames;
140 std::size_t m_Cooldown;
141 bool m_IsChangeFrame =
false;
143 unsigned long m_CooldownEndTime = 0;
144 double m_TimeBetweenFrameUpdate = 0;
146 std::size_t m_Index = 0;
Definition Drawable.hpp:14
Animation(const std::vector< std::string > &paths, bool play, std::size_t interval, bool looping=true, std::size_t cooldown=100)
Constructor for Animation class.
void Pause()
Pause the animation. If the animation has already been paused, this method won't do anything.
int GetCooldown() const
Get the cooldown time.
Definition Animation.hpp:58
State
Enum representing the state of the animation.
Definition Animation.hpp:22
@ PAUSE
Definition Animation.hpp:24
@ ENDED
Definition Animation.hpp:26
@ COOLDOWN
Definition Animation.hpp:25
@ PLAY
Definition Animation.hpp:23
void Play()
Start playing the animation. If the animation is already playing, this method won't do anything....
void Draw(const Core::Matrices &data) override
Draw the current frame.
int GetInterval() const
Get the interval between frames.
Definition Animation.hpp:46
void SetLooping(bool looping)
Set whether the animation loops.
Definition Animation.hpp:94
void SetCooldown(int cooldown)
Set the cooldown time.
Definition Animation.hpp:100
void SetInterval(int interval)
Set the interval between frames.
Definition Animation.hpp:88
bool GetLooping() const
Check if the animation loops.
Definition Animation.hpp:52
std::size_t GetCurrentFrameIndex() const
Get the index of the current frame.
Definition Animation.hpp:64
glm::vec2 GetSize() const override
Get the size of the current frame.
Definition Animation.hpp:82
State GetState() const
Get the current state of the animation.
Definition Animation.hpp:76
std::size_t GetFrameCount() const
Get the total number of frames in the animation.
Definition Animation.hpp:70
void SetCurrentFrame(std::size_t index)
Set the current frame of the animation.
Useful tools for development.
Definition Animation.hpp:12
Definition Drawable.hpp:9