Skip to content

GraphicsAPI reference

Class AnimationClip

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

An immutable sequence of sprites played at a fixed rate, or with a duration per frame (Aseprite timing).

C#
public sealed class AnimationClip

Inheritance

object ← AnimationClip

Constructors

AnimationClip(IEnumerable<Sprite>, IEnumerable<float>, bool)

Creates a clip whose frames each show for their own time, in seconds; frames and durations are copied.

C#
public AnimationClip(IEnumerable<Sprite> frames, IEnumerable<float> frameDurations, bool loop = true)

Parameters

frames IEnumerable<Sprite>

The frames in playing order.

frameDurations IEnumerable<float>

One positive duration per frame, in seconds.

loop bool

Whether the clip repeats.

Exceptions

ArgumentException

No frames, or not one duration per frame.

ArgumentOutOfRangeException

A duration is not positive.

AnimationClip(IEnumerable<Sprite>, float, bool)

Creates a clip; the frames are copied.

C#
public AnimationClip(IEnumerable<Sprite> frames, float framesPerSecond, bool loop = true)

Parameters

frames IEnumerable<Sprite>

The frames, for example from Frames.

framesPerSecond float

Playback rate; must be positive.

loop bool

Whether the clip repeats.

Exceptions

ArgumentException

frames is empty.

ArgumentOutOfRangeException

framesPerSecond is not positive.

Properties

Duration

Length of one pass through the frames, in seconds.

C#
public float Duration { get; }

Property Value

float

FrameDurations

How long each frame shows, in seconds (all equal for a clip with a fixed rate).

C#
public IReadOnlyList<float> FrameDurations { get; }

Property Value

IReadOnlyList<float>

Frames

The frames in playing order (at least one).

C#
public IReadOnlyList<Sprite> Frames { get; }

Property Value

IReadOnlyList<Sprite>

FramesPerSecond

Playback rate in frames per second; for a clip with a duration per frame, its average rate.

C#
public float FramesPerSecond { get; }

Property Value

float

Loop

Whether the clip starts over after its last frame; otherwise it holds the last frame.

C#
public bool Loop { get; }

Property Value

bool

Methods

FrameAt(float)

The frame shown time seconds after the clip started (0 or more).

C#
public Sprite FrameAt(float time)

Parameters

time float

Returns

Sprite