问题描述:

I am drawing a line in XNA by using a paint picture of one pixel, then fitting that pixel into a rectangle of height 100, with 2, so it appears as a line. This way I can later draw a rectangle.

I also want to rotate the rectangle but the rotation center is always it's upper left corner. How can I change this?

网友答案:

Use this overload of the Draw method. You'll probably want to set the origin parameter to a non-zero vector.

网友答案:

Set the Origin parameter in the Draw() method.

public void Draw (
     Texture2D texture,
     Vector2 position,
     Nullable<Rectangle> sourceRectangle,
     Color color,
     float rotation,
     Vector2 origin,
     Vector2 scale,
     SpriteEffects effects,
     float layerDepth

)

Where:

origin

The sprite origin; the default is (0,0) which represents the upper-left corner.

相关阅读:
Top