Drives Component::Animation and updates Component::Sprite accordingly.
More...
#include <AnimationSystem.hpp>
|
| void | Update (const float deltaT) override |
| | Updates all animations.
|
| virtual void | Draw () const |
| | Renders the system.
|
|
| static Component::Animation | GridAnimation (const Texture2D texture, const u32 cellWidth, const u32 cellHeight, const u32 startIndex, u32 endIndex, const float duration, const bool loop) |
| | Creates an Animation component from a sprite sheet grid.
|
| static void | Play (const Entity entity, const Component::Animation &animation) |
| | Starts playing an animation on an entity.
|
| static void | Stop (const Entity entity) |
| | Pauses the animation.
|
| static void | Resume (const Entity entity) |
| | Resumes a paused animation.
|
| static bool | IsPlaying (const Entity entity) |
| | Checks whether an animation is currently playing.
|
| static void | SetSpeed (const Entity entity, float speed) |
| | Sets the playback speed multiplier.
|
◆ GridAnimation()
| Component::Animation AnimationSystem::GridAnimation |
( |
const Texture2D | texture, |
|
|
const u32 | cellWidth, |
|
|
const u32 | cellHeight, |
|
|
const u32 | startIndex, |
|
|
u32 | endIndex, |
|
|
const float | duration, |
|
|
const bool | loop ) |
|
static |
Creates an Animation component from a sprite sheet grid.
- Parameters
-
| texture | Sprite sheet texture. |
| cellWidth | Width of each frame in pixels. |
| cellHeight | Height of each frame in pixels. |
| startIndex | First frame index (row‑major order). |
| endIndex | Last frame index (inclusive). |
| duration | Seconds per frame. |
| loop | True to repeat the animation. |
- Returns
- A fully initialised Animation component.
- Note
- Asserts if texture invalid, cell sizes zero, or index range is invalid.
◆ IsPlaying()
| bool AnimationSystem::IsPlaying |
( |
const Entity | entity | ) |
|
|
static |
Checks whether an animation is currently playing.
- Parameters
-
| entity | Entity with an Animation component. |
- Returns
- True if animation exists, is playing, and has at least one frame.
◆ Play()
Starts playing an animation on an entity.
- Parameters
-
| entity | Target entity. |
| animation | The animation data to play. |
Replaces any existing Animation component. If no Sprite component exists, one is created using the first frame of the animation.
◆ Resume()
| void AnimationSystem::Resume |
( |
const Entity | entity | ) |
|
|
static |
Resumes a paused animation.
- Parameters
-
| entity | Entity with an Animation component. |
◆ SetSpeed()
| void AnimationSystem::SetSpeed |
( |
const Entity | entity, |
|
|
float | speed ) |
|
static |
Sets the playback speed multiplier.
- Parameters
-
| entity | Entity with an Animation component. |
| speed | Speed factor (1.0 = normal, 2.0 = double speed). |
◆ Stop()
| void AnimationSystem::Stop |
( |
const Entity | entity | ) |
|
|
static |
Pauses the animation.
- Parameters
-
| entity | Entity with an Animation component. |
◆ Update()
| void AnimationSystem::Update |
( |
const float | deltaT | ) |
|
|
overridevirtual |
Updates all animations.
- Parameters
-
| deltaT | Time since last update (seconds). |
Advances the animation time, calculates the current frame, and updates the sprite's texture rectangle.
Implements System.
The documentation for this class was generated from the following files: