Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having this weird problem where the position ocmponent of a rectangle of the XNA type is offsetting the position the sprite is rendered to as well.

I guess a broader question I'm trying to have answered is: how can I make 4 integer values: top, left, bottom, right (in texture space) the equivalent of an XNA rectangle?

share|improve this question
up vote 3 down vote accepted

There are two rectangles when drawing a texture with spritebatch (also depends on which overload you are using), the source rectangle specifies where in the texture the image is take from (you can specify this as null to use the entire texture), the destination rectangle specifies where this image will be drawn on screen.

The source rectangle is mainly used to load sprite animations that are stored in one texture.

For example this is a sprite sheet in which 3 animations are encoded.

sprite sheet

share|improve this answer
Since this is in XNA would it be better for resources to have the bottom line be the second line but flipped horizontally or to use SpriteEffects to achieve the same effect? – Harold May 9 '11 at 7:19
Yes you could of course do that, the spritesheet is just the first one that I found on bing. – Roy T. May 9 '11 at 16:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.