This project has moved and is read-only. For the latest updates, please go here.

Body draws with an offset when using an origin

Topics: User Forum
Dec 18, 2013 at 5:38 PM
I am starting to work with farseer 3.5 & XNA 4, and I have created a rectangle body and used the ConvertUnits method to draw a texture in it's place on the screen. All is well except when I draw using an origin, the texture is offset by half.

My rectangle is 64x64 pixels, and my offset is set to 32,32. It rotates in the center like it should, but the texture is off the body by half. When no origin is set, the texture lines up perfectly. Do I have to convert the origin? What am I missing?
Dec 18, 2013 at 6:37 PM
I was able to get it working by adjusting the location of the sprite after converting it and before drawing it. That is strange though. I am still not certain why this occurs.

Vector2 temp = ConvertUnits.ToDisplayUnits(boxes[x].Position);
spriteBatch.Draw(boxtexture, new Vector2(temp.X + 32, temp.Y + 32), null, Color.Red, boxes[x].Rotation, boxorigin, 1f, SpriteEffects.None, 0f);