public void Draw(SpriteHook sprite, Vector2 position, SpriteBatch spriteBatch) { spriteBatch.Draw(textures[sprite].GetTexture(), position, Color.White); }
public void DrawCentered(SpriteHook sprite, Rectangle targetRect, SpriteBatch spriteBatch) { DrawCentered(textures[sprite].GetTexture(), targetRect, spriteBatch); }
public void DrawScaled(SpriteHook sprite, Rectangle destination, SpriteBatch spriteBatch) { spriteBatch.Draw(textures[sprite].GetTexture(), destination, Color.White); }
public void DrawRotatedAndScaled(SpriteHook sprite, Rectangle destination, float rotationInRadians, SpriteBatch spriteBatch) { // Alter the destination (x, y) so that the sprite rotates about its center instead of the origin. int originalX = destination.X; int originalY = destination.Y; int centerX = originalX + destination.Width / 2; int centerY = originalY + destination.Height / 2; double radius = Math.Sqrt(destination.Width * destination.Width + destination.Height * destination.Height) / 2.0; double originalAngle = Math.Asin((centerY - originalY) / radius) - Math.PI; destination.X = (int)Math.Round(centerX + radius * Math.Cos(rotationInRadians + originalAngle)); destination.Y = (int)Math.Round(centerY + radius * Math.Sin(rotationInRadians + originalAngle)); spriteBatch.Draw(textures[sprite].GetTexture(), destination, null, Color.White, rotationInRadians, new Vector2(), SpriteEffects.None, 0); }
public void DrawRotatedAndCentered(SpriteHook sprite, Rectangle destination, float rotationInRadians, SpriteBatch spriteBatch) { int centerX = destination.Center.X; int centerY = destination.Center.Y; int width = textures[sprite].GetTexture().Width; int height = textures[sprite].GetTexture().Height; destination.X = centerX - width / 2; destination.Y = centerY - height / 2; destination.Width = width; destination.Height = height; DrawRotatedAndScaled(sprite, destination, rotationInRadians, spriteBatch); }
public void DrawLayer(SpriteHook sprite, Rectangle targetRect, SpriteBatch spriteBatch) { spriteBatch.Draw(textures[sprite].GetTexture(), targetRect, targetRect, Color.White); }
public void DrawLayer(SpriteHook sprite, SpriteBatch spriteBatch) { spriteBatch.Draw(textures[sprite].GetTexture(), new Vector2(), Color.White); }