buster2001

I need am 2D object to be rotate 90 degrees each time a press down a key. What would be the best to do this. I have try to use TransFormatins of a vector but I can't ge it to work.



Re: XNA Framework Rotate an object

George Clingerman

The sprite batch draw method has an override that will rotate the current image by a certain amount. Just create a new variable in your object to track current rotation and then increment that by 90 degress every time they press a key. Then pass that in to the SpriteBatch.Draw method.





Re: XNA Framework Rotate an object

buster2001

I know that. I need it to rotate on command when I press a button or a mouse click. I need something better because I will have from 3-20 object doing thing at a time. Some with rotate +/- .



Re: XNA Framework Rotate an object

George Clingerman

There's really nothing better than that. You know how to detect Mouse clicks and keyboard input so when the user press that button. Increase the rotate value for that object or objects that need to be rotate.

Then when they are drawn, you use that current rotation value. You really can't get much better rotation than that.

Is there something in particular you're not understanding Or am I misunderstanding what you are trying to accomplish





Re: XNA Framework Rotate an object

Zaex

What if i want to translate the object by its local orientation afterwards How would i go about doing that I tried using quaternions, to no avail.




Re: XNA Framework Rotate an object

buster2001

Ok I see what u are saying and it will work. What I am doing is samething like this. When I Left_click on obj_0 it will rotate -90 or 270 deg and obj_1 and obj_3 will rotate + 90 deg.