I'm hitting my head against a brick wall here, trying to draw a texture around an object's position in my engine. I've been modifying the code to supply an origin to the SpriteBatch so I can get rotation to work properly... but am not having much luck.
So given the following draw code :
Vector2 objectCenter = aComponentObject.Position; float halfWidth = aComponentObject.Size.X / 2.0f; float halfHeight = aComponentObject.Size.Y / 2.0f; Rectangle objectBounds = new Rectangle( (int)(objectCenter.X - halfWidth), (int)(objectCenter.Y - halfHeight), (int)aComponentObject.Size.X, (int)aComponentObject.Size.Y ); aSpriteBatch.Draw( aTextureManager.GetColourMap(graphicComponent.ColourMapID), objectBounds, null, drawColour, aComponentObject.Rotation, objectCenter, SpriteEffects.None, 0.0f );
I would have thought that the 'objectCenter' parameter passed in to the draw call would properly offset my object's rendering (given I have an object at (100,100) with a size of (200,200)... instead I get the following :
Only half of the object is being rendered, where what I'm actually after (moving the camera up and left) is more like this :
Here the mouse is position in the dead center of the object.
Any ideas what I'm doing wrong?
Thanks for your help!