AnimationComponent.cs 731 B

1234567891011121314151617181920212223242526272829
  1. using System.Collections.Generic;
  2. using Microsoft.Xna.Framework;
  3. namespace MonoGame.Extended.Animations
  4. {
  5. public class AnimationComponent : GameComponent
  6. {
  7. public AnimationComponent(Game game)
  8. : base(game)
  9. {
  10. Animations = new List<AnimationController>();
  11. }
  12. public List<AnimationController> Animations { get; }
  13. public override void Update(GameTime gameTime)
  14. {
  15. base.Update(gameTime);
  16. for (var i = Animations.Count - 1; i >= 0; i--)
  17. {
  18. var animation = Animations[i];
  19. animation.Update(gameTime);
  20. }
  21. Animations.RemoveAll(a => a.IsDisposed);
  22. }
  23. }
  24. }