Table of Contents

Class SpriteAnimationGroup

Namespace
MLEM.Animations
Assembly
MLEM.dll

Represents a list of SpriteAnimation objects with a condition and priority attached to them. Sprite animation groups can be used if any single entity should have multiple animations (like up, down, left, right standing and running animations) that should be automatically managed.

public class SpriteAnimationGroup : GenericDataHolder, IGenericDataHolder
Inheritance
SpriteAnimationGroup
Implements
Inherited Members

Properties

Count

Returns the amount of SpriteAnimation entries that this sprite animation group has.

public int Count { get; }

Property Value

int

CurrentAnimation

Returns the animation that is currently playing.

public SpriteAnimation CurrentAnimation { get; }

Property Value

SpriteAnimation

CurrentFrame

Returns the frame that CurrentAnimation is displaying.

public AnimationFrame CurrentFrame { get; }

Property Value

AnimationFrame

CurrentRegion

public TextureRegion CurrentRegion { get; }

Property Value

TextureRegion

CurrentRegions

public IList<TextureRegion> CurrentRegions { get; }

Property Value

IList<TextureRegion>

this[int]

Returns the SpriteAnimation at the given index.

public SpriteAnimation this[int index] { get; }

Parameters

index int

The index.

Property Value

SpriteAnimation

this[string]

Returns the SpriteAnimation in this animation group with the given Name, if it exists, and null otherwise.

public SpriteAnimation this[string name] { get; }

Parameters

name string

The name of the animation.

Property Value

SpriteAnimation

SpeedMultiplier

The speed multiplier that this animation should run with. Numbers higher than 1 will increase the speed.

public float SpeedMultiplier { set; }

Property Value

float

Methods

Add(SpriteAnimation, Func<bool>, int)

Adds a SpriteAnimation to this group.

public SpriteAnimationGroup Add(SpriteAnimation anim, Func<bool> condition, int priority = 0)

Parameters

anim SpriteAnimation

The animation to add

condition Func<bool>

The condition that needs to be met for this animation to play

priority int

The priority of this animation. The higher the priority, the earlier it is picked for playing.

Returns

SpriteAnimationGroup

This group, for chaining

ByName(string)

Find an animation in this group by name and returns it.

[Obsolete("Use the name-based indexer instead")]
public SpriteAnimation ByName(string name)

Parameters

name string

The Name of the animation

Returns

SpriteAnimation

The animation by that name, or null if there is none

Update(GameTime)

Updates this animation, causing TimeIntoAnimation to be increased and the CurrentFrame to be updated.

public void Update(GameTime time)

Parameters

time GameTime

The game's time

Update(TimeSpan)

Updates this animation, causing TimeIntoAnimation to be increased and the CurrentFrame to be updated.

public void Update(TimeSpan elapsed)

Parameters

elapsed TimeSpan

The amount of time that has passed

Events

OnAnimationChanged

A callback for when the currently displaying animation has changed due to a condition with a higher priority being met.

public event SpriteAnimationGroup.AnimationChanged OnAnimationChanged

Event Type

SpriteAnimationGroup.AnimationChanged