← API Reference Struct

asge::game::components::Animation

Frame-by-frame playback state for a spritesheet — see systems::AnimationSystem, which steps m_CurrentFrame and writes the current frame of m_Clip's FrameTable into the owning entity's Sprite::m_SourceRect each frame.

#include <Animation.hpp>

The frame list itself lives in m_Clip, a shared, VFS-loaded asset::FrameTable — not embedded here — so multiple entities playing the same clip share one loaded frame list instead of each holding a copy. m_ClipPath is what actually round-trips through TOML (see Serializer< Animation> below); m_Clip stays null until asset::AssetManager:: ResolveAssets resolves it (the same deferred-load step Sprite::m_Texture goes through), so AnimationSystem has nothing to advance for a freshly loaded/spawned entity until that's run at least once.

m_ResolvedClipPath (also runtime-only) is what m_Clip was actually last resolved from — Resolver<Animation> compares it against m_ClipPath to notice a change (repointing to a new clip) or a clear (path emptied out, m_Clip released back to null), rather than resolving once and never again.

Ownership: this Animation owns the Sprite's m_SourceRect only while it is playing. AnimationSystem saves the Sprite's own crop into m_RestRect when playback starts, overwrites m_SourceRect every frame, and puts m_RestRect back once m_Playing goes false (one system run later, so a finished non-looping clip's last frame is shown for that run) or m_ClipPath is cleared. Removing the Animation mid-playback is the caller's job: the Sprite keeps the last frame's rect unless m_RestRect is written back first (the level editor's Remove handler does).

Public Types

#using frame_table = std::shared_ptr< asset::Asset< asset::FrameTable > >

Public Attributes

#str::String m_ClipPath {}
#std::map< str::String, str::String, std::less<> > m_Clips {}
#frame_table m_Clip {}
#str::String m_ResolvedClipPath {}
#float m_FrameDuration {0.1f}
#float m_PlaybackSpeed {1.0f}
#std::size_t m_CurrentFrame {0}
#float m_ElapsedTime {0.0f}
#bool m_Loop {true}
#bool m_StartPlaying {true}
#bool m_Playing {true}
#std::optional< math::Rect > m_RestRect {}
#bool m_OwnsSourceRect {false}