Skip to content

GraphicsAPI reference

Class Animator

Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics2D.dll
Guide: Graphics

Plays named clips; switching to the clip already playing does not restart it.

C#
public sealed class Animator

Inheritance

object ← Animator

Constructors

Animator()

C#
public Animator()

Properties

Current

The clip playing, or null before the first clip is added.

C#
public AnimationClip? Current { get; }

Property Value

AnimationClip?

CurrentName

Name of the clip playing, or null before the first clip is added.

C#
public string? CurrentName { get; }

Property Value

string?

Finished

Whether a non-looping clip has reached its end. Always false for looping clips.

C#
public bool Finished { get; }

Property Value

bool

Frame

The frame to draw now.

C#
public Sprite Frame { get; }

Property Value

Sprite

Exceptions

InvalidOperationException

No clip was added.

Speed

Playback speed multiplier: 1 by default, 0 pauses, 2 plays twice as fast.

C#
public float Speed { get; set; }

Property Value

float

Exceptions

ArgumentOutOfRangeException

Set to a negative value or NaN (clips do not play backwards).

Time

Seconds played in the current clip, scaled by Speed; reset to 0 when another clip starts.

C#
public float Time { get; }

Property Value

float

Methods

Add(string, AnimationClip)

Registers clip under name (replacing a clip with that name). The first clip added starts playing.

C#
public Animator Add(string name, AnimationClip clip)

Parameters

name string

clip AnimationClip

Returns

Animator

This animator, for chaining.

Exceptions

ArgumentNullException

clip is null.

Play(string, bool)

Switches to the clip name from its first frame. Playing the current clip again does nothing unless restart is true.

C#
public void Play(string name, bool restart = false)

Parameters

name string

restart bool

Exceptions

KeyNotFoundException

No clip has that name.

Update(float)

Advances the current clip by dt seconds times Speed.

C#
public void Update(float dt)

Parameters

dt float