i've been trying to get a sprite to face my cursor using XNA, it works almost perfectly, but instead of the centre of the face of the sprite, it's the corner that points to the cursor... which is no good for a game where something in the centre of the sprite must face the cursor, just wondering if there's a way to make it point from a certain point... that sounds confusing but i hope somebody gets it :)
heres the code im using:
to get the angle:
direction = mousePos - position;
rotation = (float)Math.Atan2(direction.Y, direction.X);
to Draw the sprite:
spriteBatch.Begin();
spriteBatch.Draw(sprite, position, null, Color.White, rotation + 90, origin, 1.0f, SpriteEffects.None, 0);
spriteBatch.End();
so if this is my sprite: [ ] the top left corner will point to the cursor, not the middle :P
rotation + 45
orrotation - 45
– thedaianorigin
to the center of the sprite correctly? – Andrew Russell