0
\$\begingroup\$

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?

\$\endgroup\$
3
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Harold May 9 '11 at 7:19
  • \$\begingroup\$ Yes you could of course do that, the spritesheet is just the first one that I found on bing. \$\endgroup\$ – Roy T. May 9 '11 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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