Particle.cs 650 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Graphics;
  8. namespace Tutorial030.Sprites
  9. {
  10. public class Particle : Sprite
  11. {
  12. public Vector2 Velocity;
  13. public Particle(Texture2D texture)
  14. : base(texture)
  15. {
  16. Origin = new Vector2(_texture.Width / 2, _texture.Height / 2);
  17. }
  18. public override void Update(GameTime gameTime)
  19. {
  20. Position += Velocity;
  21. if (Position.Y > (Game1.ScreenHeight + _texture.Height))
  22. IsRemoved = true;
  23. }
  24. }
  25. }