![]() |
R-Type
2
Doom but in better
|
#include <AnimationComponent.hpp>
Public Member Functions | |
AnimationComponent () | |
Construct a new Animation Component object. | |
AnimationComponent (const std::uint32_t entityId) | |
Construct a new Animation Component object with the entity id. | |
AnimationComponent (const std::vector< Recoded::IntRect > &rects) | |
Construct a new Animation Component object with: | |
AnimationComponent (const std::string &path, const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) | |
Construct a new Animation Component object with: | |
AnimationComponent (const GUI::ECS::Components::TextureComponent &spritesheet, const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) | |
Construct a new Animation Component object with: | |
AnimationComponent (const std::uint32_t entityId, const std::vector< Recoded::IntRect > &rects) | |
Construct a new Animation Component object with: | |
AnimationComponent (const std::uint32_t entityId, const std::string &path, const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) | |
Construct a new Animation Component object with: | |
AnimationComponent (const std::uint32_t entityId, const GUI::ECS::Components::TextureComponent &spritesheet, const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) | |
Construct a new Animation Component object with: | |
~AnimationComponent () | |
Destroy the Animation Component object. | |
void | setLoop (bool loop) |
Set the Loop object. | |
void | setReadReverse (bool reverse) |
Set the Read Reverse object. | |
void | setDelay (float frameDuration) |
Set the Delay object. | |
void | setInitialFrame (std::uint32_t frameIndex) |
Set the Initial Frame object. | |
void | setAnimation (const std::vector< Recoded::IntRect > &rects) |
Set the Animation object. | |
void | setAnimation (const std::string &path, const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) |
Set the Animation object. | |
void | setAnimation (const GUI::ECS::Components::TextureComponent &spritesheet, const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) |
Set the Animation object. | |
void | checkTick () |
Check if it is time to change the frame of the animation. | |
void | forceTick () |
Force the animation to tick regardless of the delay. | |
void | start () |
Start the playing of the animation from the current index in memory. | |
void | pause () |
Pause the playing of the animation but does not reset the index to the default frame. | |
void | resume () |
Resume the playing of the animation (has no effect if already playing) | |
void | stop () |
A function to stop the animation, and reset the index to the default frame. | |
const bool | hasTicked () |
A function to check if the frame has changed. | |
const bool | hasLooped () const |
A function to check if the animation has looped around (valid for the 1rst frame of the new loop) | |
const bool | isLooping () const |
Get the information about if the component is set to loop the animation. | |
const bool | isPaused () const |
Get the information about the state of the animation (paused) | |
const bool | isPlaying () const |
Get the information about the state of the animation (playing) | |
const bool | isStopped () const |
Get the information about the state of the animation (stopped) | |
void | update (const GUI::ECS::Components::AnimationComponent ©) |
Update the current Animation component with another Animation class. | |
const bool | getTicked () const |
A function to check if the frame has changed. | |
const bool | getPaused () const |
Get the information about the state of the animation (paused/playing) | |
const bool | getPlaying () const |
Get the information about the state of the animation (paused/playing) | |
const bool | getStopped () const |
Get the information about the state of the animation (paused/playing) | |
const bool | getLooped () const |
Get the information about if the animation has completed a loop (valid for the 1rst frame of the new loop) | |
const bool | getLoop () const |
Get the info about if the animation is being read in a loop or not (once at the end, go back to the begining and start over) | |
const bool | getReadReverse () const |
Get the info about if the order of the frames are being read from right to left instead of left to right. | |
const float | getDelay () const |
Get the Delay object that is used before changing frames. | |
const std::uint32_t | getFrameCount () const |
Get the total number of frames contained in the animation. | |
const std::uint32_t | getInitialFrame () const |
Get the index of the frame considered as the first in the series of the animation. | |
const std::uint32_t | getCurrentFrameIndex () const |
Get the index of the frame that is currently in use. | |
const Recoded::IntRect | getCurrentFrame () const |
Get the index of the frame that is currently in use. | |
const GUI::ECS::Components::TextureComponent | getBaseTexture () const |
Get the Base Texture object. | |
const std::pair< int, int > | getFrameDimensions () const |
Get the dimension of the first frame under an std::pair<int, int> instance. | |
const Recoded::IntRect | getCurrentRectangle () const |
Get the Rectangle that is currently in use. | |
const std::vector< Recoded::IntRect > | getFrames () const |
Get all the frames loaded in the animation component. | |
const std::string | getInfo (const unsigned int indent=0) const |
This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes. | |
const GUI::ECS::Systems::Clock | getClock () const |
Get the Clock object. | |
AnimationComponent & | operator= (const GUI::ECS::Components::AnimationComponent ©) |
![]() | |
EntityNode (const size_t entityId=0) | |
virtual | ~EntityNode ()=default |
virtual size_t | getEntityNodeId () const |
Protected Member Functions | |
void | _tick () |
Main function to process the ticking of the animation. | |
void | _tickReverse () |
Advances the animation by one frame in reverse. | |
void | _tickRegular () |
Advances the animation by one frame in regular (forward) order. | |
void | _processAnimation (const unsigned int frameWidth, const unsigned int frameHeight, const bool startLeft, const bool startTop, const unsigned int initialFrame=0, const int endFrame=(-1)) |
Function in charge of generating the animation frames based on the provided information. | |
const short int | _getIndexUpdater (const bool startBegining=true) const |
const bool | _continueLoop (const bool startBegining, const unsigned int position, const unsigned int maxValue) const |
Protected Attributes | |
bool | _looped = false |
A boolean instance in charge of informing the user that the program has looped (valid for the first 2 frames after the loop has occurred) | |
bool | _loop = false |
A boolean instance in charge of informing the program to play the animation as a loop. | |
bool | _paused = false |
A boolean instance in charge of informing the program to not play the animation but retain the current position. | |
bool | _playing = false |
A boolean instance in charge of informing the program to play or resume the animation. | |
bool | _stopped = false |
A boolean instance in charge of informing the program to not play the animation as well as resetting the index to the default one. | |
bool | _hasTicked = false |
A boolean instance in charge of informing the user that the frame has been changed. | |
bool | _readReverse = false |
A boolean instance in charge of informing the program to read the animation backwards. | |
std::uint32_t | _frameDelay = 100 |
An unsigned integer to store the delay to wait between each frame. | |
std::uint32_t | _frameInitial = 0 |
An unsigned integer to store the index of the initial frame (the default frame) | |
std::uint32_t | _currentFrameIndex = 0 |
An unsigned integer to store the index of the frame that is currently active. | |
std::uint32_t | _totalFrames = 0 |
An unsigned integer to store the total amount of frames in the animation. | |
GUI::ECS::Components::TextureComponent | _baseTexture |
A Texture component to store the base texture that is used to derive all the animations rectangles. | |
std::vector< Recoded::IntRect > | _frames |
An std::vector of Rectangle components to store all the derived frames of the animation. | |
Recoded::IntRect | _currentRectangle |
A Rectangle component to store the frame that is to be displayed. | |
GUI::ECS::Systems::Clock | _clock |
A clock component that allows the Animation component to track time and know when to change frames. | |
![]() | |
size_t | _entityID |
Definition at line 35 of file AnimationComponent.hpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | ) |
Construct a new Animation Component object.
Definition at line 16 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const std::uint32_t | entityId | ) |
Construct a new Animation Component object with the entity id.
entityId | The id of the component |
Definition at line 21 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const std::vector< Recoded::IntRect > & | rects | ) |
Construct a new Animation Component object with:
rects | The loaded IntRects ready to be played |
Definition at line 26 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const std::string & | path, |
const unsigned int | frameWidth, | ||
const unsigned int | frameHeight, | ||
const bool | startLeft, | ||
const bool | startTop, | ||
const unsigned int | initialFrame = 0, | ||
const int | endFrame = (-1) ) |
Construct a new Animation Component object with:
path | |
frameWidth | |
frameHeight | |
startLeft | |
startTop |
Definition at line 32 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const GUI::ECS::Components::TextureComponent & | spritesheet, |
const unsigned int | frameWidth, | ||
const unsigned int | frameHeight, | ||
const bool | startLeft, | ||
const bool | startTop, | ||
const unsigned int | initialFrame = 0, | ||
const int | endFrame = (-1) ) |
Construct a new Animation Component object with:
spritesheet | Path to the spritesheet |
frameWidth | Width of the frame for the sprite |
frameHeight | Height of the frame for the sprite |
startLeft | Start parsing the animation from the left |
startTop | Start parsing the animation from the top |
Definition at line 38 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const std::uint32_t | entityId, |
const std::vector< Recoded::IntRect > & | rects ) |
Construct a new Animation Component object with:
entityId | Id of the component |
rects | The IntRects ready to be played |
Definition at line 44 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const std::uint32_t | entityId, |
const std::string & | path, | ||
const unsigned int | frameWidth, | ||
const unsigned int | frameHeight, | ||
const bool | startLeft, | ||
const bool | startTop, | ||
const unsigned int | initialFrame = 0, | ||
const int | endFrame = (-1) ) |
Construct a new Animation Component object with:
entityId | Id of the component |
spritesheet | Path to the spritesheet |
frameWidth | Width of the frame for the sprite |
frameHeight | Height of the frame for the sprite |
startLeft | Start parsing the animation from the left |
startTop | Start parsing the animation from the top |
Definition at line 50 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::AnimationComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Components::TextureComponent & | spritesheet, | ||
const unsigned int | frameWidth, | ||
const unsigned int | frameHeight, | ||
const bool | startLeft, | ||
const bool | startTop, | ||
const unsigned int | initialFrame = 0, | ||
const int | endFrame = (-1) ) |
Construct a new Animation Component object with:
entityId | Id of the component |
spritesheet | The spritsheet |
frameWidth | Width of the frame for the sprite |
frameHeight | Height of the frame for the sprite |
startLeft | Start parsing the animation from the left |
startTop | Start parsing the animation from the top |
Definition at line 56 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent::~AnimationComponent | ( | ) |
Destroy the Animation Component object.
Definition at line 64 of file AnimationComponent.cpp.
|
protected |
Definition at line 734 of file AnimationComponent.cpp.
|
protected |
Definition at line 726 of file AnimationComponent.cpp.
|
protected |
Function in charge of generating the animation frames based on the provided information.
frameWidth | The width of the resulting sprite |
frameHeight | The height of the resulting sprite |
startLeft | Start from the left |
startTop | Start from the top |
Definition at line 505 of file AnimationComponent.cpp.
|
protected |
Main function to process the ticking of the animation.
This function is responsible for advancing the current frame of the animation. It first checks if the animation is paused, if there are frames to render, and if the initial frame is valid. It then calls either _tickRegular()
or _tickReverse()
based on the direction of the animation (forward or reverse).
If the animation is paused, no frame is updated. If there are no frames or if the initial frame is invalid, appropriate exceptions are thrown. This function decides whether to proceed with regular or reverse ticking of the frames.
CustomExceptions::InvalidIndex | If there are no frames, or if the frame index exceeds the valid range. |
Definition at line 410 of file AnimationComponent.cpp.
|
protected |
Advances the animation by one frame in regular (forward) order.
This function is responsible for incrementing the current frame index in forward order. If the next frame exceeds the total number of frames, the index is reset either to the first frame or the initial frame, depending on whether looping is enabled. The current frame is then updated.
CustomExceptions::InvalidIndex | If the initial frame is invalid or greater than the total number of frames. |
Definition at line 476 of file AnimationComponent.cpp.
|
protected |
Advances the animation by one frame in reverse.
This function is responsible for decrementing the current frame index in reverse order. If the next frame is out of bounds (i.e., the index becomes negative), the frame index is reset either to the last frame or the initial frame depending on whether looping is enabled. The current frame is then updated.
CustomExceptions::InvalidIndex | If the initial frame is invalid or greater than the total number of frames. |
Definition at line 445 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::checkTick | ( | ) |
Check if it is time to change the frame of the animation.
Definition at line 121 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::forceTick | ( | ) |
Force the animation to tick regardless of the delay.
Definition at line 130 of file AnimationComponent.cpp.
const GUI::ECS::Components::TextureComponent GUI::ECS::Components::AnimationComponent::getBaseTexture | ( | ) | const |
Get the Base Texture object.
Definition at line 339 of file AnimationComponent.cpp.
const GUI::ECS::Systems::Clock GUI::ECS::Components::AnimationComponent::getClock | ( | ) | const |
Get the Clock object.
Definition at line 396 of file AnimationComponent.cpp.
const Recoded::IntRect GUI::ECS::Components::AnimationComponent::getCurrentFrame | ( | ) | const |
Get the index of the frame that is currently in use.
Definition at line 320 of file AnimationComponent.cpp.
const std::uint32_t GUI::ECS::Components::AnimationComponent::getCurrentFrameIndex | ( | ) | const |
Get the index of the frame that is currently in use.
Definition at line 309 of file AnimationComponent.cpp.
const Recoded::IntRect GUI::ECS::Components::AnimationComponent::getCurrentRectangle | ( | ) | const |
Get the Rectangle that is currently in use.
Definition at line 356 of file AnimationComponent.cpp.
const float GUI::ECS::Components::AnimationComponent::getDelay | ( | ) | const |
Get the Delay object that is used before changing frames.
Definition at line 294 of file AnimationComponent.cpp.
const std::uint32_t GUI::ECS::Components::AnimationComponent::getFrameCount | ( | ) | const |
Get the total number of frames contained in the animation.
Definition at line 299 of file AnimationComponent.cpp.
const std::pair< int, int > GUI::ECS::Components::AnimationComponent::getFrameDimensions | ( | ) | const |
Get the dimension of the first frame under an std::pair<int, int> instance.
CustomExceptions::NoAnimationFrames | if there are no frames to read the content from. |
Definition at line 344 of file AnimationComponent.cpp.
const std::vector< Recoded::IntRect > GUI::ECS::Components::AnimationComponent::getFrames | ( | ) | const |
Get all the frames loaded in the animation component.
Definition at line 361 of file AnimationComponent.cpp.
const std::string GUI::ECS::Components::AnimationComponent::getInfo | ( | const unsigned int | indent = 0 | ) | const |
This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.
indent | The level to which the class should be indented in the dump. |
Definition at line 366 of file AnimationComponent.cpp.
const std::uint32_t GUI::ECS::Components::AnimationComponent::getInitialFrame | ( | ) | const |
Get the index of the frame considered as the first in the series of the animation.
Definition at line 304 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getLoop | ( | ) | const |
Get the info about if the animation is being read in a loop or not (once at the end, go back to the begining and start over)
Definition at line 284 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getLooped | ( | ) | const |
Get the information about if the animation has completed a loop (valid for the 1rst frame of the new loop)
hasLooped
Definition at line 279 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getPaused | ( | ) | const |
Get the information about the state of the animation (paused/playing)
isPaused
Definition at line 264 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getPlaying | ( | ) | const |
Get the information about the state of the animation (paused/playing)
isPlaying
Definition at line 269 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getReadReverse | ( | ) | const |
Get the info about if the order of the frames are being read from right to left instead of left to right.
Definition at line 289 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getStopped | ( | ) | const |
Get the information about the state of the animation (paused/playing)
isStopped
Definition at line 274 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::getTicked | ( | ) | const |
A function to check if the frame has changed.
hasTicked
Definition at line 259 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::hasLooped | ( | ) | const |
A function to check if the animation has looped around (valid for the 1rst frame of the new loop)
Definition at line 182 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::hasTicked | ( | ) |
A function to check if the frame has changed.
Definition at line 173 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::isLooping | ( | ) | const |
Get the information about if the component is set to loop the animation.
Definition at line 187 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::isPaused | ( | ) | const |
Get the information about the state of the animation (paused)
Definition at line 192 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::isPlaying | ( | ) | const |
Get the information about the state of the animation (playing)
Definition at line 197 of file AnimationComponent.cpp.
const bool GUI::ECS::Components::AnimationComponent::isStopped | ( | ) | const |
Get the information about the state of the animation (stopped)
Definition at line 202 of file AnimationComponent.cpp.
GUI::ECS::Components::AnimationComponent & GUI::ECS::Components::AnimationComponent::operator= | ( | const GUI::ECS::Components::AnimationComponent & | copy | ) |
Definition at line 401 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::pause | ( | ) |
Pause the playing of the animation but does not reset the index to the default frame.
Definition at line 146 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::resume | ( | ) |
Resume the playing of the animation (has no effect if already playing)
Definition at line 155 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::setAnimation | ( | const GUI::ECS::Components::TextureComponent & | spritesheet, |
const unsigned int | frameWidth, | ||
const unsigned int | frameHeight, | ||
const bool | startLeft, | ||
const bool | startTop, | ||
const unsigned int | initialFrame = 0, | ||
const int | endFrame = (-1) ) |
Set the Animation object.
spritesheet | |
frameWidth | |
frameHeight | |
startLeft | |
startTop |
Definition at line 115 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::setAnimation | ( | const std::string & | path, |
const unsigned int | frameWidth, | ||
const unsigned int | frameHeight, | ||
const bool | startLeft, | ||
const bool | startTop, | ||
const unsigned int | initialFrame = 0, | ||
const int | endFrame = (-1) ) |
Set the Animation object.
path | |
frameWidth | |
frameHeight | |
startLeft | |
startTop |
Definition at line 109 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::setAnimation | ( | const std::vector< Recoded::IntRect > & | rects | ) |
void GUI::ECS::Components::AnimationComponent::setDelay | ( | float | frameDuration | ) |
Set the Delay object.
frameDuration |
Definition at line 76 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::setInitialFrame | ( | std::uint32_t | frameIndex | ) |
Set the Initial Frame object.
frameIndex |
Definition at line 91 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::setLoop | ( | bool | loop | ) |
void GUI::ECS::Components::AnimationComponent::setReadReverse | ( | bool | reverse | ) |
Set the Read Reverse object.
reverse |
Definition at line 71 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::start | ( | ) |
Start the playing of the animation from the current index in memory.
Definition at line 137 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::stop | ( | ) |
A function to stop the animation, and reset the index to the default frame.
Definition at line 164 of file AnimationComponent.cpp.
void GUI::ECS::Components::AnimationComponent::update | ( | const GUI::ECS::Components::AnimationComponent & | copy | ) |
Update the current Animation component with another Animation class.
copy |
Definition at line 207 of file AnimationComponent.cpp.
|
protected |
A Texture component to store the base texture that is used to derive all the animations rectangles.
Definition at line 485 of file AnimationComponent.hpp.
|
protected |
A clock component that allows the Animation component to track time and know when to change frames.
Definition at line 488 of file AnimationComponent.hpp.
|
protected |
An unsigned integer to store the index of the frame that is currently active.
Definition at line 483 of file AnimationComponent.hpp.
|
protected |
A Rectangle component to store the frame that is to be displayed.
Definition at line 487 of file AnimationComponent.hpp.
|
protected |
An unsigned integer to store the delay to wait between each frame.
Definition at line 481 of file AnimationComponent.hpp.
|
protected |
An unsigned integer to store the index of the initial frame (the default frame)
Definition at line 482 of file AnimationComponent.hpp.
|
protected |
An std::vector of Rectangle components to store all the derived frames of the animation.
Definition at line 486 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the user that the frame has been changed.
Definition at line 479 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the program to play the animation as a loop.
Definition at line 475 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the user that the program has looped (valid for the first 2 frames after the loop has occurred)
Definition at line 474 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the program to not play the animation but retain the current position.
Definition at line 476 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the program to play or resume the animation.
Definition at line 477 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the program to read the animation backwards.
Definition at line 480 of file AnimationComponent.hpp.
|
protected |
A boolean instance in charge of informing the program to not play the animation as well as resetting the index to the default one.
Definition at line 478 of file AnimationComponent.hpp.
|
protected |
An unsigned integer to store the total amount of frames in the animation.
Definition at line 484 of file AnimationComponent.hpp.