12 #include <SFML/Audio/Music.hpp>
13 #include <SFML/Graphics/RectangleShape.hpp>
14 #include <SFML/Graphics/Texture.hpp>
15 #include <SFML/Graphics.hpp>
16 #include <SFML/Audio/Sound.hpp>
17 #include <SFML/Graphics/Sprite.hpp>
18 #include <SFML/System/Vector2.hpp>
19 #include <SFML/Window/Keyboard.hpp>
20 #include <SFML/Audio.hpp>
35 Animation(sf::Vector2u textureSize = {0, 0});
61 bool addAnimation(
const std::string& name,
int frameCount, sf::Vector2u frameSize, sf::Vector2u startPosition,
float fps = 12.0f,
bool loop =
true);
74 void update(
float deltaTime);
120 sf::Vector2u frameSize;
121 sf::Vector2u startPosition;
134 sf::IntRect _textureRect;
135 sf::Vector2u _textureSize;
136 std::unordered_map<std::string, AnimationData> _animations;
137 std::string _currentAnimationName;
139 float _timeAccumulator;
A class that handles sprite animations.
Definition Animation.hpp:27
const sf::IntRect & getTextureRect() const
Gets the texture rectangle for the current frame.
Definition Animation.cpp:241
bool isPlaying() const
Checks if the animation is playing.
Definition Animation.cpp:156
bool setCurrentAnimation(const std::string &name, bool resetFrame=true)
Sets the current animation.
Definition Animation.cpp:77
std::string getCurrentAnimationName() const
Gets the current animation name.
Definition Animation.cpp:165
void setTextureSize(sf::Vector2u textureSize)
Sets the texture size for the animation.
Definition Animation.cpp:34
void play()
Plays the current animation.
Definition Animation.cpp:128
void pause()
Pauses the current animation.
Definition Animation.cpp:136
bool addAnimation(const std::string &name, int frameCount, sf::Vector2u frameSize, sf::Vector2u startPosition, float fps=12.0f, bool loop=true)
Adds an animation to the animation list.
Definition Animation.cpp:50
void setFlipX(bool flip)
Sets whether the sprite should be flipped horizontally.
Definition Animation.cpp:174
void stop()
Stops the current animation and resets it.
Definition Animation.cpp:144
void updateTextureRect()
Updates the texture rectangle for the current frame.
Definition Animation.cpp:198
void setFlipY(bool flip)
Sets whether the sprite should be flipped vertically.
Definition Animation.cpp:186
Animation(sf::Vector2u textureSize={0, 0})
Constructor for Animation class.
Definition Animation.cpp:15
void update(float deltaTime)
Updates the animation based on elapsed time.
Definition Animation.cpp:101
~Animation()
Destructor for Animation class.
Definition Animation.cpp:25
Structure to store animation data.
Definition Animation.hpp:117