Struct Engine::Animation¶
ClassList > Engine > Animation
ECS Component managing animation clip collections and runtime playback state. More...
#include <Animation.hpp>
Public Attributes¶
| Type | Name |
|---|---|
| std::unordered_map< std::string, AnimationClip > | clips |
| std::string | currentAnimation = "" |
| std::size_t | currentFrame = 0 |
| bool | flipX = false |
| bool | flipY = false |
| bool | isPlaying = true |
| float | offsetX = 0.0f |
| float | offsetY = 0.0f |
| float | scaleX = 1.0f |
| float | scaleY = 1.0f |
| std::vector< std::shared_ptr< Sprite > > | sprites |
| float | timer = 0.0f |
Public Functions¶
| Type | Name |
|---|---|
| Animation () = default Default constructor. |
|
| Animation (std::vector< std::string > paths, float frameDuration=0.1f, bool loop=true, float offsetX=0.0f, float offsetY=0.0f, float scaleX=1.0f, float scaleY=1.0f, bool flipX=false, bool flipY=false, const std::string & clipName="Idle") Helper constructor initializing an Animation component with a multi-file clip. |
|
| Animation (const std::string & sheetPath, float frameWidth, float frameHeight, std::size_t totalFrames=0, float frameDuration=0.1f, bool loop=true, float offsetX=0.0f, float offsetY=0.0f, float scaleX=1.0f, float scaleY=1.0f, bool flipX=false, bool flipY=false, const std::string & clipName="Idle") Helper constructor initializing an Animation component with a uniform grid clip. |
|
| Animation (const std::string & sheetPath, std::vector< FrameData > frames, float frameDuration=0.1f, bool loop=true, float offsetX=0.0f, float offsetY=0.0f, float scaleX=1.0f, float scaleY=1.0f, bool flipX=false, bool flipY=false, const std::string & clipName="Idle") Helper constructor initializing an Animation component with explicitFrameData . |
|
| const AnimationClip * | GetCurrentClip () const Gets a const pointer to the currently active AnimationClip . |
| AnimationClip * | GetCurrentClip () Gets a mutable pointer to the currently active AnimationClip . |
| bool | Play (const std::string & clipName, bool restartIfSame=false) Switches active animation state and resets playback counters. |
Detailed Description¶
Contains all animation clips assigned to an entity, runtime playback counters, texture instance caches, and spatial transformations (scale, offset, mirroring).
Public Attributes Documentation¶
variable clips¶
Map of clip names to their static configuration.
variable currentAnimation¶
Key of the currently active animation clip.
variable currentFrame¶
Index of the currently displayed frame.
variable flipX¶
Mirrors sprite horizontally when rendered.
variable flipY¶
Mirrors sprite vertically when rendered.
variable isPlaying¶
Controls active playback advancement.
variable offsetX¶
Horizontal anchor offset added to Entity Position.x.
variable offsetY¶
Vertical anchor offset added to Entity Position.y.
variable scaleX¶
Horizontal scale multiplier.
variable scaleY¶
Vertical scale multiplier.
variable sprites¶
Cached runtime sprite instances for active asset paths.
variable timer¶
Accumulated delta time for current frame step.
Public Functions Documentation¶
function Animation [¼]¶
Default constructor.
function Animation [2/4]¶
Helper constructor initializing an Animation component with a multi-file clip.
Engine::Animation::Animation (
std::vector< std::string > paths,
float frameDuration=0.1f,
bool loop=true,
float offsetX=0.0f,
float offsetY=0.0f,
float scaleX=1.0f,
float scaleY=1.0f,
bool flipX=false,
bool flipY=false,
const std::string & clipName="Idle"
)
Parameters:
pathsList of image file paths.frameDurationTime per frame in seconds.loopEnables continuous looping.offsetXWorld position horizontal offset.offsetYWorld position vertical offset.scaleXHorizontal scale factor.scaleYVertical scale factor.flipXHorizontal flip flag.flipYVertical flip flag.clipNameDefault clip identifier name.
function Animation [¾]¶
Helper constructor initializing an Animation component with a uniform grid clip.
Engine::Animation::Animation (
const std::string & sheetPath,
float frameWidth,
float frameHeight,
std::size_t totalFrames=0,
float frameDuration=0.1f,
bool loop=true,
float offsetX=0.0f,
float offsetY=0.0f,
float scaleX=1.0f,
float scaleY=1.0f,
bool flipX=false,
bool flipY=false,
const std::string & clipName="Idle"
)
Parameters:
sheetPathPath to spritesheet image.frameWidthCell frame width in pixels.frameHeightCell frame height in pixels.totalFramesTotal frame count.frameDurationTime per frame in seconds.loopEnables continuous looping.offsetXWorld position horizontal offset.offsetYWorld position vertical offset.scaleXHorizontal scale factor.scaleYVertical scale factor.flipXHorizontal flip flag.flipYVertical flip flag.clipNameDefault clip identifier name.
function Animation [4/4]¶
Helper constructor initializing an Animation component with explicitFrameData .
Engine::Animation::Animation (
const std::string & sheetPath,
std::vector< FrameData > frames,
float frameDuration=0.1f,
bool loop=true,
float offsetX=0.0f,
float offsetY=0.0f,
float scaleX=1.0f,
float scaleY=1.0f,
bool flipX=false,
bool flipY=false,
const std::string & clipName="Idle"
)
Parameters:
sheetPathPath to texture atlas.framesArray of FrameData frame specifications.frameDurationTime per frame in seconds.loopEnables continuous looping.offsetXWorld position horizontal offset.offsetYWorld position vertical offset.scaleXHorizontal scale factor.scaleYVertical scale factor.flipXHorizontal flip flag.flipYVertical flip flag.clipNameDefault clip identifier name.
function GetCurrentClip [½]¶
Gets a const pointer to the currently active AnimationClip .
Returns:
Pointer to active AnimationClip, or nullptr if no valid clip is active.
function GetCurrentClip [2/2]¶
Gets a mutable pointer to the currently active AnimationClip .
Returns:
Pointer to active AnimationClip, or nullptr if no valid clip is active.
function Play¶
Switches active animation state and resets playback counters.
Parameters:
clipNameName key of the clip to play.restartIfSameIf true, restarts playback from frame 0 even if already playing.
Returns:
True if the requested clip exists and was activated, false otherwise.
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Components/Animation.hpp