Polygon Dash
Loading...
Searching...
No Matches
ComponentAnimation Class Reference

Chose the correct animation frame to display. More...

Inheritance diagram for ComponentAnimation:
IComponent

Public Member Functions

 this (size_t owner, SDL_Renderer *renderer, string jsonPath)
 Setup the renderer.
 
override void Update ()
 Update the current frame in the animation if enough time has passed.
 
override void Render (SDL_Renderer *renderer, SDL_Rect *camera)
 Render the given component.
 
SDL_Texture * getSpritesheet ()
 Get the loaded spritesheet texture.
 
SDL_Rect getCurrentFrameRect ()
 Get the spritesheet region corresponding to the current frame.
 
void Load (SDL_Renderer *renderer, string jsonPath)
 Load a texture from a .bmp file.
 
- Public Member Functions inherited from IComponent

Public Attributes

SDL_Texture * mSpritesheet
 The loaded SDL texture of the spritesheet.
 
Frame[] mFrames
 A list of Frame objects in the animation.
 
int mCurrentFrame
 The index of the current frame.
 
uint mLastFrameTime
 The time when the last frame was rendered.
 
Random rng
 A random generator.
 

Detailed Description

Chose the correct animation frame to display.

The rendering is done by ComponentRender.

See also
ComponentRender

Constructor & Destructor Documentation

◆ this()

ComponentAnimation::this ( size_t owner,
SDL_Renderer * renderer,
string jsonPath )
inline

Setup the renderer.

Parameters
ownerthe id of the attached GameObject.
rendererthe SDL renderer object.
jsonPaththe JSON file defining the sprite animation parameters.

Member Function Documentation

◆ getCurrentFrameRect()

SDL_Rect ComponentAnimation::getCurrentFrameRect ( )
inline

Get the spritesheet region corresponding to the current frame.

Returns
An SDL_Rect that maps to the loaded texture.

◆ getSpritesheet()

SDL_Texture * ComponentAnimation::getSpritesheet ( )
inline

Get the loaded spritesheet texture.

Returns
The loaded SDL_Texture*.

◆ Load()

void ComponentAnimation::Load ( SDL_Renderer * renderer,
string jsonPath )
inline

Load a texture from a .bmp file.

Parameters
rendererthe SDL renderer object.
jsonPaththe JSON file defining the sprite animation parameters.

◆ Render()

override void ComponentAnimation::Render ( SDL_Renderer * renderer,
SDL_Rect * camera )
inline

Render the given component.

Implements IComponent.

◆ Update()

override void ComponentAnimation::Update ( )
inline

Update the current frame in the animation if enough time has passed.

See also
mCurrentFrame
mLastFrameTime

Implements IComponent.


The documentation for this class was generated from the following file: