Engine
Raylib based game framework
Loading...
Searching...
No Matches
AnimationSystem Class Reference

Drives Component::Animation and updates Component::Sprite accordingly. More...

#include <AnimationSystem.hpp>

Inheritance diagram for AnimationSystem:
Collaboration diagram for AnimationSystem:

Public Member Functions

void Update (const float deltaT) override
 Updates all animations.
Public Member Functions inherited from System
virtual void Draw () const
 Renders the system.

Static Public Member Functions

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.

Detailed Description

Drives Component::Animation and updates Component::Sprite accordingly.

Member Function Documentation

◆ 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
textureSprite sheet texture.
cellWidthWidth of each frame in pixels.
cellHeightHeight of each frame in pixels.
startIndexFirst frame index (row‑major order).
endIndexLast frame index (inclusive).
durationSeconds per frame.
loopTrue 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
entityEntity with an Animation component.
Returns
True if animation exists, is playing, and has at least one frame.

◆ Play()

void AnimationSystem::Play ( const Entity entity,
const Component::Animation & animation )
static

Starts playing an animation on an entity.

Parameters
entityTarget entity.
animationThe 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
entityEntity with an Animation component.

◆ SetSpeed()

void AnimationSystem::SetSpeed ( const Entity entity,
float speed )
static

Sets the playback speed multiplier.

Parameters
entityEntity with an Animation component.
speedSpeed factor (1.0 = normal, 2.0 = double speed).

◆ Stop()

void AnimationSystem::Stop ( const Entity entity)
static

Pauses the animation.

Parameters
entityEntity with an Animation component.

◆ Update()

void AnimationSystem::Update ( const float deltaT)
overridevirtual

Updates all animations.

Parameters
deltaTTime 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: