API Animation - shmellyorc/Box GitHub Wiki

Animation

Namespace: Box.Entities.Graphics

Description

A read-only structure that encapsulates all data necessary to describe a frame-based animation: its unique name, the source surface containing the sprite sheet, an array of frame rectangles, playback speed, and whether it should loop. It also provides a quick check for emptiness when no frames are defined or speed is zero, and a human-readable representation via ToString().

Constructor

Initializes all readonly properties of the animation. This constructor is internal and is typically invoked by AnimatedSprite when registering new animations.

Properties

Property Description
string Name Identifier for the animation sequence.
Surface Surface Sprite sheet or texture containing the animation frames.
Rect2[] Frames Array of source rectangles defining each frame’s region on the surface.
float Speed Playback speed in frames per second (FPS).
bool Looped True if the animation should restart automatically after the final frame.
bool IsEmpty True if the animation has no frames or if Speed is zero, indicating it cannot play.

Methods

Method Signature Description Returns
public override string ToString() Returns a string in the format "{Name} ({Frames.Length} frames)", useful for debugging and logging animation data. string