using Microsoft.Xna.Framework; using MLEM.Animations; namespace MLEM.Ui.Elements { /// /// A sprite animation image for use inside of a . /// A sprite animation image is an that displays a or . /// public class SpriteAnimationImage : Image { /// /// The sprite animation group that is displayed by this image /// public SpriteAnimationGroup Group; /// /// Creates a new sprite animation image with the given settings /// /// The image's anchor /// The image's size /// The sprite animation group to display /// Whether this image element should scale to the texture public SpriteAnimationImage(Anchor anchor, Vector2 size, SpriteAnimationGroup group, bool scaleToImage = false) : base(anchor, size, group.CurrentRegion, scaleToImage) { this.Group = group; } /// /// Creates a new sprite animation image with the given settings /// /// The image's anchor /// The image's size /// The sprite group to display /// Whether this image element should scale to the texture public SpriteAnimationImage(Anchor anchor, Vector2 size, SpriteAnimation animation, bool scaleToImage = false) : this(anchor, size, new SpriteAnimationGroup().Add(animation, () => true), scaleToImage) {} /// public override void Update(GameTime time) { base.Update(time); this.Group.Update(time); this.Texture = this.Group.CurrentRegion; } } }