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
CurrentAnimation
Returns the animation that is currently playing.
public SpriteAnimation CurrentAnimation { get; }
Property Value
CurrentFrame
Returns the frame that CurrentAnimation is displaying.
public AnimationFrame CurrentFrame { get; }
Property Value
CurrentRegion
Returns the CurrentAnimation's CurrentRegion.
public TextureRegion CurrentRegion { get; }
Property Value
CurrentRegions
Returns the CurrentAnimation's CurrentRegions.
public IList<TextureRegion> CurrentRegions { get; }
Property Value
this[int]
Returns the SpriteAnimation at the given index.
public SpriteAnimation this[int index] { get; }
Parameters
indexintThe index.
Property Value
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
namestringThe name of the animation.
Property Value
SpeedMultiplier
The speed multiplier that this animation should run with. Numbers higher than 1 will increase the speed.
public float SpeedMultiplier { set; }
Property Value
Methods
Add(SpriteAnimation, Func<bool>, int)
Adds a SpriteAnimation to this group.
public SpriteAnimationGroup Add(SpriteAnimation anim, Func<bool> condition, int priority = 0)
Parameters
animSpriteAnimationThe animation to add
conditionFunc<bool>The condition that needs to be met for this animation to play
priorityintThe 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
Returns
- SpriteAnimation
The animation by that name, or
nullif 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
timeGameTimeThe 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
elapsedTimeSpanThe 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