The Table Engine
animationsmanager.h
Go to the documentation of this file.
1 // animationsmanager.h
2 #pragma once
3 
4 #include "texture.h"
5 #include "animation.h"
6 #include <vector>
7 #include <string>
8 
16 class AnimationsManager : public Texture {
17 protected:
18  std::vector<Animation*> m_animations;
19  size_t m_currentAnimation = 0;
20  bool m_isPlaying = true;
21 
22 public:
25 
31  int addAnimation(Animation* animation);
32 
41  int createAnimation(SDL_Texture* texture, int rows, int cols, float time);
42 
47  void setCurrentAnimation(size_t index);
48 
53  size_t getCurrentAnimation() const;
54 
60 
64  void play();
65 
69  void pause();
70 
75  void setFrame(int frame);
76 
81  int getCurrentFrame() const;
82 
87  bool isPlaying() const;
88 
92  void update() override;
93 
97  void render() override;
98 
99  // Overrides from Texture class
100  void setTexture(SDL_Texture* texture) override;
101  void setSizeInSpriteMap(int w, int h) override;
102  void setPositionInSpriteMap(int x, int y) override;
103  void setFlipHorizontal(bool flip) override;
104  void setFlipVertical(bool flip) override;
105  void setAngle(float angle) override;
106 };
Defines the Animation class for handling sprite animations.
Component to handle animation of game objects. Derived from Texture.
Definition: animation.h:21
Manages a collection of animations for a game entity, with functionality to play, pause,...
void setPositionInSpriteMap(int x, int y) override
Sets the position of the sprite in the sprite map.
bool m_isPlaying
Flag to check if the animation is currently playing.
size_t m_currentAnimation
Index of the currently active animation.
int createAnimation(SDL_Texture *texture, int rows, int cols, float time)
void setCurrentAnimation(size_t index)
void setFlipVertical(bool flip) override
Sets vertical flip status.
void render() override
void setTexture(SDL_Texture *texture) override
Sets the SDL_Texture object.
size_t getCurrentAnimation() const
std::vector< Animation * > m_animations
Stores pointers to Animation objects.
void update() override
void setSizeInSpriteMap(int w, int h) override
Sets the size of the sprite in the sprite map.
void setFrame(int frame)
void setFlipHorizontal(bool flip) override
Sets horizontal flip status.
int addAnimation(Animation *animation)
void setAngle(float angle) override
Sets the rotation angle of the texture.
Animation * getCurrentAnimationObject()
Component for handling textures in the game engine.
Definition: texture.h:20
Defines the Texture component for managing textures within the Game Engine, encapsulating SDL texture...