Horn Posted March 9, 2004 Posted March 9, 2004 I'm trying to get a sprite to rotate around its center and I'm not having much luck. I've tried setting the center vector to be the center of the sprite plus its current position (so if a sprite had a center of 2 and a position of 30 its new center would be 32). I then set the sprite's tranform matrix to a rotation matrix but it acts all weird. If I leave the center alone, it rotates around 0,0 (upper left corner). Can anyone help me out? Quote
GreenGoose Posted March 10, 2004 Posted March 10, 2004 (edited) I'm trying to get a sprite to rotate around its center and I'm not having much luck. I've tried setting the center vector to be the center of the sprite plus its current position (so if a sprite had a center of 2 and a position of 30 its new center would be 32). I then set the sprite's tranform matrix to a rotation matrix but it acts all weird. If I leave the center alone' date=' it rotates around 0,0 (upper left corner). Can anyone help me out?[/quote'] Given a 32x32 sprite, you want the center of the sprite to be the roation center which is 16x16 or "new Vector2(16f, 16f)". The rotation is relative to the end-result, scaled, rectangle you are using from the Texture. So if you scale the rectangle from 32x32 to 16x16, with a scaling vector of Vector2(0.5f, 0.5f), then your new center would be 8x8, and you'd want to use that for your rotation center as well. Edited March 10, 2004 by GreenGoose Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.