Practical Tools for Simple Design
Loading...
Searching...
No Matches
Util::Animation Class Reference

Class representing an animation with frames. More...

#include <Animation.hpp>

Inheritance diagram for Util::Animation:
Core::Drawable

Public Types

enum class  State { PLAY , PAUSE , COOLDOWN , ENDED }
 Enum representing the state of the animation. More...
 

Public Member Functions

 Animation (const std::vector< std::string > &paths, bool play, std::size_t interval, bool looping=true, std::size_t cooldown=100, bool useAA=true)
 Constructor for Animation class. More...
 
int GetInterval () const
 Get the interval between frames. More...
 
bool GetLooping () const
 Check if the animation loops. More...
 
int GetCooldown () const
 Get the cooldown time. More...
 
std::size_t GetCurrentFrameIndex () const
 Get the index of the current frame. More...
 
std::size_t GetFrameCount () const
 Get the total number of frames in the animation. More...
 
State GetState () const
 Get the current state of the animation. More...
 
glm::vec2 GetSize () const override
 Get the size of the current frame. More...
 
void SetInterval (int interval)
 Set the interval between frames. More...
 
void SetLooping (bool looping)
 Set whether the animation loops. More...
 
void SetCooldown (int cooldown)
 Set the cooldown time. More...
 
void UseAntiAliasing (bool useAA)
 Sets whether anti-aliasing (AA) should be enabled or disabled. More...
 
void SetCurrentFrame (std::size_t index)
 Set the current frame of the animation. More...
 
void Draw (const Core::Matrices &data) override
 Draw the current frame. More...
 
void Play ()
 Start playing the animation. If the animation is already playing, this method won't do anything. If the animation has ended and looping is set to false, this would replay the animation once.
 
void Pause ()
 Pause the animation. If the animation has already been paused, this method won't do anything.
 
virtual void Draw (const Core::Matrices &data)=0
 
virtual glm::vec2 GetSize () const =0
 

Detailed Description

Class representing an animation with frames.

Member Enumeration Documentation

◆ State

enum class Util::Animation::State
strong

Enum representing the state of the animation.

Enumerator
PLAY 

Animation is playing.

PAUSE 

Animation is paused.

COOLDOWN 

Animation is COOLDOWN.

ENDED 

Animation is Ended(looping == false && Animate end.).

Constructor & Destructor Documentation

◆ Animation()

Util::Animation::Animation ( const std::vector< std::string > &  paths,
bool  play,
std::size_t  interval,
bool  looping = true,
std::size_t  cooldown = 100,
bool  useAA = true 
)

Constructor for Animation class.

Parameters
pathsVector of file paths for the frames.
playWhether the animation should play right away.
intervalInterval between frames in milliseconds.
loopingWhether the animation should loop.
cooldownCooldown time in milliseconds before the animation can restart.

Member Function Documentation

◆ Draw()

void Util::Animation::Draw ( const Core::Matrices data)
overridevirtual

Draw the current frame.

Parameters
transformTransformation matrix for drawing.
zIndexZ-index for drawing.

Implements Core::Drawable.

◆ GetCooldown()

int Util::Animation::GetCooldown ( ) const
inline

Get the cooldown time.

Returns
Cooldown time in milliseconds.

◆ GetCurrentFrameIndex()

std::size_t Util::Animation::GetCurrentFrameIndex ( ) const
inline

Get the index of the current frame.

Returns
Index of the current frame.

◆ GetFrameCount()

std::size_t Util::Animation::GetFrameCount ( ) const
inline

Get the total number of frames in the animation.

Returns
Total number of frames.

◆ GetInterval()

int Util::Animation::GetInterval ( ) const
inline

Get the interval between frames.

Returns
Interval between frames in milliseconds.

◆ GetLooping()

bool Util::Animation::GetLooping ( ) const
inline

Check if the animation loops.

Returns
True if the animation loops, false otherwise.

◆ GetSize()

glm::vec2 Util::Animation::GetSize ( ) const
inlineoverridevirtual

Get the size of the current frame.

Returns
Size of the current frame.

Implements Core::Drawable.

◆ GetState()

State Util::Animation::GetState ( ) const
inline

Get the current state of the animation.

Returns
The current state of the animation

◆ SetCooldown()

void Util::Animation::SetCooldown ( int  cooldown)
inline

Set the cooldown time.

Parameters
cooldownCooldown time in milliseconds.

◆ SetCurrentFrame()

void Util::Animation::SetCurrentFrame ( std::size_t  index)

Set the current frame of the animation.

Parameters
indexIndex of the frame to set as current.

◆ SetInterval()

void Util::Animation::SetInterval ( int  interval)
inline

Set the interval between frames.

Parameters
intervalInterval between frames in milliseconds.

◆ SetLooping()

void Util::Animation::SetLooping ( bool  looping)
inline

Set whether the animation loops.

Parameters
loopingTrue to enable looping, false to disable.

◆ UseAntiAliasing()

void Util::Animation::UseAntiAliasing ( bool  useAA)

Sets whether anti-aliasing (AA) should be enabled or disabled.

Parameters
useAAA boolean value indicating whether anti-aliasing should be enabled (true) or disabled (false).
Note
This function only sets the internal flag for anti-aliasing and does not directly affect rendering. The actual effect of anti-aliasing depends on the rendering pipeline and the graphics hardware capabilities.
See also
https://en.wikipedia.org/wiki/Spatial_anti-aliasing

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