SpriteInstanceclass

A sprite resource with independent animation playback. Call Update once per update, then draw the current frame as many times as needed with Painter.Sprite.

object→SpriteInstance
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.SpriteInstance

Constructors1

Showing 1 constructors

public SpriteInstance(Sandbox.Sprite sprite)PUBLICCONSTRUCTOR

Creates independent playback starting at the sprite's first animation.

ParameterTypeDescription
spriteSprite—

Methods2

Showing 2 methods

public void Play(string animation, bool restart = False)PUBLIC

Selects an animation by name and resumes playback. Playing the selected animation preserves its position unless restart is true. An unknown name leaves playback unchanged.

ParameterTypeDescription
animationstring—
restart = Falsebool—
Returns:void—

public void Update(float deltaTime)PUBLICPER-FRAME

Advances playback by elapsed seconds, respecting the animation's frame rate and loop points. Drawing does not call this method. Frame broadcast actions are not executed by this instance.

ParameterTypeDescription
deltaTimefloat—
Returns:void—

Properties8

Showing 8 properties

public int Sandbox.SpriteInstance.CurrentFrameIndex { get; set; }PUBLICGETSET

The current frame index. Setting it clears elapsed frame time and completion state. An out-of-range index has no frame to draw.

Returns:int—

public bool Sandbox.SpriteInstance.IsFinished { get; set; }PUBLICGETSET

True after a non-looping animation has finished. Cleared by switching, restarting or seeking.

Returns:bool—

public bool Sandbox.SpriteInstance.Paused { get; set; }PUBLICGETSET

Pauses advancement without discarding elapsed frame time.

Returns:bool—

public float Sandbox.SpriteInstance.PlaybackSpeed { get; set; }PUBLICGETSET

Playback multiplier. Zero stops advancement; negative values play backwards.

Returns:float—

public Sandbox.Sprite Sandbox.SpriteInstance.Sprite { get; set; }PUBLICGETSET

The sprite to play. Changing it selects its first animation and resets playback. A null sprite has no frame to draw.

Returns:Sprite—

On this page