Animation.cs 898 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Microsoft.Xna.Framework.Graphics;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Tutorial020.Models
  8. {
  9. public class Animation : ICloneable
  10. {
  11. public int CurrentFrame { get; set; }
  12. public int FrameCount { get; private set; }
  13. public int FrameHeight { get { return Texture.Height; } }
  14. public float FrameSpeed { get; set; }
  15. public int FrameWidth { get { return Texture.Width / FrameCount; } }
  16. public bool IsLooping { get; set; }
  17. public Texture2D Texture { get; private set; }
  18. public Animation(Texture2D texture, int frameCount)
  19. {
  20. Texture = texture;
  21. FrameCount = frameCount;
  22. IsLooping = true;
  23. FrameSpeed = 0.2f;
  24. }
  25. public object Clone()
  26. {
  27. return this.MemberwiseClone();
  28. }
  29. }
  30. }