I'm having interesting problem with rotating a sprite in MonoGame. Here is how origin, destination rectangle and scale are created:
Vector2 origin = new Vector2(tx.Width / 2, tx.Height / 2);
Rectangle dstRectangle = new Rectangle((int)e.Xpos, (int)e.Ypos, (int)(tx.Width), (int)(tx.Height));
dstRectangle.X += (tx.Width / 2);
dstRectangle.Y += (tx.Height / 2);
Vector2 scale = new Vector2(tx.Width * (float)TxScaleFactor, tx.Height * (float)TxScaleFactor);
And here is the draw function:
Editor.spriteBatch.Draw(texture: GlowWhite, destinationRectangle: dstRectangle, color: Tint * (Alpha * 0.6f), rotation: rotation, scale: scale, origin: origin);
Now, with angle 0.0f, everything is fine but any additional rotations become weird:
- And 180 deg
Its like there is some kind of offset - I've tried to change 0 to 90, and back 0 and next to 180 - result is always the same (apparently, there is no adding). I'm guessing that problem is related to origin, destination rectangle or scale. Sprites are rotated in place as you can see (no issues with that) but something with rotation isn't right. Any ideas?