I can easily rotate sprites using the Draw method. However I would like to simply rotate a Rectangle (the structure) so that I can get the coordinate of the four corners of the rectangle. How can I do that?
|
You can't rotate a Microsoft.Xna.Framework.Rectangle. It is by nature an axis aligned structure only. What do you hope to do with the corners that you want to find? Maybe we could suggest a good way to accomplish your goal. |
|||
|
|
|
You can make for all 4 points something like this:
Code From MSDN http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector2.aspx |
|||
|
|
If you want to get the coordinates of the rotated corners, you have to transform the coordinates from the non-rotated space to the rotated space. In other words, you have to multiply them by a matrix. I'm not sure the exact xna syntax, but it should be something like this:
This will rotate the rectangle about it's top left corner. I'm not sure if that's what you want or not, but you can easily change this by adding a translate transform before the rotate transform to change the rotation origin. |
|||
|
|