Sprite.cs 776 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Tutorial014.Sprites
  9. {
  10. public class Sprite : Component
  11. {
  12. protected Texture2D _texture;
  13. public Vector2 Position { get; set; }
  14. public Rectangle Rectangle
  15. {
  16. get { return new Rectangle((int)Position.X, (int)Position.Y, _texture.Width, _texture.Height); }
  17. }
  18. public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
  19. {
  20. spriteBatch.Draw(_texture, Position, Color.White);
  21. }
  22. public Sprite(Texture2D texture)
  23. {
  24. _texture = texture;
  25. }
  26. public override void Update(GameTime gameTime)
  27. {
  28. }
  29. }
  30. }