Provides functions to add sprites and update animation. More...
#include <AnimationComponent.hpp>
Public Member Functions | |
AnimationComponent (SDL_Renderer *ren) | |
Constructor. More... | |
AnimationComponent () | |
~AnimationComponent () | |
Destructor. More... | |
void | Update (PLAYER_STATE targetState, PLAYER_DIR movingDir, int posX, int posY) |
Update animation state and the sprite in the source texture. More... | |
void | Render (SDL_Renderer *ren) |
Render the animation to the active viewport. More... | |
void | AddSprite (ANIMATION_STATE spriteName, Sprite *newSprite) |
Add sprites needed for animation. More... | |
void | UpdateState (ANIMATION_STATE newState) |
Update the state of the animation. More... | |
Sprite * | GetCurrSprite () |
get the currently playing sprite. This is for determining the sprite play progress as some operations like knockback relies on it. More... | |
ANIMATION_STATE | GetState () |
return the animation state. More... | |
Sprite * | GetSprite (ANIMATION_STATE newState) |
get a specific animation sprite More... | |
Public Member Functions inherited from Component | |
Component () | |
~Component () | |
Provides functions to add sprites and update animation.
AnimationComponent::AnimationComponent | ( | SDL_Renderer * | ren | ) |
Constructor.
ren | Reference to SDL renderer. |
AnimationComponent::AnimationComponent | ( | ) |
AnimationComponent::~AnimationComponent | ( | ) |
Destructor.
void AnimationComponent::AddSprite | ( | ANIMATION_STATE | spriteName, |
Sprite * | newSprite | ||
) |
Add sprites needed for animation.
Sprite * AnimationComponent::GetCurrSprite | ( | ) |
get the currently playing sprite. This is for determining the sprite play progress as some operations like knockback relies on it.
Sprite * AnimationComponent::GetSprite | ( | ANIMATION_STATE | newState | ) |
get a specific animation sprite
newState | Current animation state. |
ANIMATION_STATE AnimationComponent::GetState | ( | ) |
return the animation state.
void AnimationComponent::Render | ( | SDL_Renderer * | ren | ) |
Render the animation to the active viewport.
ren | Reference to SDL renderer. |
void AnimationComponent::Update | ( | PLAYER_STATE | targetState, |
PLAYER_DIR | movingDir, | ||
int | posX, | ||
int | posY | ||
) |
Update animation state and the sprite in the source texture.
targetState | The state of the gameobject in the next frame. |
movingDir | Moving direction. |
posX | The x location of the sprite in the source texture. |
posY | The y location of the sprite in the source texture. |
void AnimationComponent::UpdateState | ( | ANIMATION_STATE | newState | ) |
Update the state of the animation.
newState | The new animation state. |