The Table Engine
|
Manages a collection of animations for a game entity, with functionality to play, pause, and switch between animations. More...
#include <animationsmanager.h>
Public Member Functions | |
AnimationsManager () | |
~AnimationsManager () | |
int | addAnimation (Animation *animation) |
int | createAnimation (SDL_Texture *texture, int rows, int cols, float time) |
void | setCurrentAnimation (size_t index) |
size_t | getCurrentAnimation () const |
Animation * | getCurrentAnimationObject () |
void | play () |
void | pause () |
void | setFrame (int frame) |
int | getCurrentFrame () const |
bool | isPlaying () const |
void | update () override |
void | render () override |
void | setTexture (SDL_Texture *texture) override |
Sets the SDL_Texture object. More... | |
void | setSizeInSpriteMap (int w, int h) override |
Sets the size of the sprite in the sprite map. More... | |
void | setPositionInSpriteMap (int x, int y) override |
Sets the position of the sprite in the sprite map. More... | |
void | setFlipHorizontal (bool flip) override |
Sets horizontal flip status. More... | |
void | setFlipVertical (bool flip) override |
Sets vertical flip status. More... | |
void | setAngle (float angle) override |
Sets the rotation angle of the texture. More... | |
![]() | |
Texture () | |
Default constructor for the Texture class, initializes an empty texture. More... | |
Texture (SDL_Texture *texture) | |
Constructor with texture initialization. More... | |
SDL_Texture * | getTexture () |
Retrieves the SDL_Texture object. More... | |
void | setColorMod (const SDL_Color &color) |
Sets the color modulation for the texture. More... | |
![]() | |
Component () | |
Default constructor for the Component. More... | |
Component (std::string name) | |
Constructs a Component with a specified name. More... | |
virtual | ~Component () |
Virtual destructor for safe polymorphic use. More... | |
std::string | getName () |
Retrieves the name of the component. More... | |
GameObject * | getOwner () |
Retrieves the GameObject that owns this component. More... | |
void | setName (std::string name) |
Sets the name of the component. More... | |
void | setOwner (GameObject *owner) |
Sets the GameObject owner of this component. More... | |
virtual void | input () |
Virtual method for handling input, intended to be overridden by derived components. More... | |
Protected Attributes | |
std::vector< Animation * > | m_animations |
Stores pointers to Animation objects. More... | |
size_t | m_currentAnimation = 0 |
Index of the currently active animation. More... | |
bool | m_isPlaying = true |
Flag to check if the animation is currently playing. More... | |
![]() | |
SDL_Texture * | m_texture |
Pointer to the SDL_Texture object. More... | |
SDL_Renderer * | m_renderer |
Pointer to the SDL_Renderer associated with this texture. More... | |
SDL_Rect * | m_spriteBox |
Destination rectangle on the screen for rendering the texture. More... | |
SDL_Rect * | m_spriteClip |
Source rectangle in the sprite sheet for slicing the texture. More... | |
bool | m_flipHorizontal = false |
Flag for horizontal flipping of the texture. More... | |
bool | m_flipVertical = false |
Flag for vertical flipping of the texture. More... | |
float | m_angle = 0.0f |
Rotation angle of the texture in degrees. More... | |
![]() | |
std::string | m_name |
Name of the component, useful for identification or debugging. More... | |
GameObject * | m_owner |
Pointer to the GameObject that owns this component. More... | |
Manages a collection of animations for a game entity, with functionality to play, pause, and switch between animations.
AnimationsManager extends Texture, allowing it to directly control the rendering of animations based on the Texture properties.
Definition at line 16 of file animationsmanager.h.
AnimationsManager::AnimationsManager | ( | ) |
Definition at line 4 of file animationsmanager.cpp.
AnimationsManager::~AnimationsManager | ( | ) |
Definition at line 8 of file animationsmanager.cpp.
int AnimationsManager::addAnimation | ( | Animation * | animation | ) |
Adds a new Animation object to the manager.
animation | Pointer to the Animation to add. |
Definition at line 58 of file animationsmanager.cpp.
int AnimationsManager::createAnimation | ( | SDL_Texture * | texture, |
int | rows, | ||
int | cols, | ||
float | time | ||
) |
Creates a new animation directly from texture details and adds it to the manager.
texture | Pointer to the SDL_Texture resource. |
rows | Number of rows in the sprite sheet. |
cols | Number of columns in the sprite sheet. |
time | Duration of each animation frame. |
Definition at line 65 of file animationsmanager.cpp.
size_t AnimationsManager::getCurrentAnimation | ( | ) | const |
Retrieves the index of the currently active animation.
Definition at line 76 of file animationsmanager.cpp.
Animation * AnimationsManager::getCurrentAnimationObject | ( | ) |
Gets the Animation object of the currently active animation.
Definition at line 86 of file animationsmanager.cpp.
int AnimationsManager::getCurrentFrame | ( | ) | const |
Gets the current frame number of the animation.
Definition at line 113 of file animationsmanager.cpp.
bool AnimationsManager::isPlaying | ( | ) | const |
Checks if the animation is currently playing.
Definition at line 72 of file animationsmanager.cpp.
void AnimationsManager::pause | ( | ) |
Pauses the current animation.
Definition at line 100 of file animationsmanager.cpp.
void AnimationsManager::play | ( | ) |
Starts or resumes playing the current animation.
Definition at line 93 of file animationsmanager.cpp.
|
overridevirtual |
Renders the current frame of the animation. Should be called per frame.
Reimplemented from Texture.
Definition at line 126 of file animationsmanager.cpp.
|
overridevirtual |
Sets the rotation angle of the texture.
angle | Rotation angle in degrees. |
Reimplemented from Texture.
Definition at line 51 of file animationsmanager.cpp.
void AnimationsManager::setCurrentAnimation | ( | size_t | index | ) |
Sets the currently active animation.
index | Index of the animation to make active. |
Definition at line 80 of file animationsmanager.cpp.
|
overridevirtual |
Sets horizontal flip status.
flip | True to flip the texture horizontally, false otherwise. |
Reimplemented from Texture.
Definition at line 37 of file animationsmanager.cpp.
|
overridevirtual |
Sets vertical flip status.
flip | True to flip the texture vertically, false otherwise. |
Reimplemented from Texture.
Definition at line 44 of file animationsmanager.cpp.
void AnimationsManager::setFrame | ( | int | frame | ) |
Sets the frame number of the current animation.
frame | Frame number to set. |
Definition at line 107 of file animationsmanager.cpp.
|
overridevirtual |
Sets the position of the sprite in the sprite map.
x | Horizontal position of the sprite in the sprite sheet. |
y | Vertical position of the sprite in the sprite sheet. |
Reimplemented from Texture.
Definition at line 30 of file animationsmanager.cpp.
|
overridevirtual |
Sets the size of the sprite in the sprite map.
w | Width of the sprite in the sprite sheet. |
h | Height of the sprite in the sprite sheet. |
Reimplemented from Texture.
Definition at line 23 of file animationsmanager.cpp.
|
overridevirtual |
Sets the SDL_Texture object.
texture | Pointer to the new SDL_Texture to be managed. |
Reimplemented from Texture.
Definition at line 15 of file animationsmanager.cpp.
|
overridevirtual |
Updates the current animation state. Should be called per frame.
Reimplemented from Texture.
Definition at line 120 of file animationsmanager.cpp.
|
protected |
Stores pointers to Animation objects.
Definition at line 18 of file animationsmanager.h.
|
protected |
Index of the currently active animation.
Definition at line 19 of file animationsmanager.h.
|
protected |
Flag to check if the animation is currently playing.
Definition at line 20 of file animationsmanager.h.