public Sprite(TextureRect textureRect, Vector2 position, Vector2 scale, float rotation, Color color) { this.textureRect = textureRect; this.position = position; this.scale = scale; this.rotation = rotation; this.color = color; this.HitBox = new Rect(position, textureRect.size.ToVector2()); }
public Particle(TextureRect texture, Vector2 position, Vector2 scale, float rotation, float decayTime = 1f, Vector2?gravity = null, Vector2?startVelocity = null) : base(texture, position, scale, rotation, Color.White) { this.decayTime = decayTime; this.gravity = gravity == null ? new Vector2(0, 0) : (Vector2)gravity; this.velocity = startVelocity == null ? new Vector2(0, 0) : (Vector2)startVelocity; this.colorTween.Start(Color.White, Color.Transparent, decayTime, ScaleFuncs.Linear); this.scaleTween.Start(scale, new Vector2(0, 0), decayTime, ScaleFuncs.Linear); }
public static void Draw(this SpriteBatch spriteBatch, TextureRect textureRect, Vector2 position, Vector2 scale, Color color, float rotation = 0, float depth = 0) { spriteBatch.Draw(textureRect.texture, position, textureRect.currentRectangle, color, rotation, textureRect.currentRectangle.Size.ToVector2() / 2, scale, SpriteEffects.None, depth); }