Search code examples
c#xnatexture2d

Rotate 2D texture XNA


I'm trying to rotate my shot Texture by 180 degress, but when I do the following:

spriteBatch.Draw(TexTiro, Position, null, Color.White, (float)(180), new Vector2(), Vector2.One, SpriteEffects.None, 0f);

the texture appears like this: enter image description here

What am I doing wrong?


Solution

  • It is because the rotation is in radians.

    You can use MathHelper.ToRadians() to easily convert degrees to radians: see here

    spriteBatch.Draw(TexTiro, Position, null, Color.White, MathHelper.ToRadians(180), new Vector2(), Vector2.One, SpriteEffects.None, 0f);