# Sprite not visible when using a Rectangle for collision in XNA

When I added a Rectangle to the Draw method for the sprite, it did not show up on screen.

 spriteBatch.Draw(texture, position, new Rectangle((int)position.X, (int)position.Y, (int)texture.Width, (int)texture.Height), Color.White, rotation, orgin, scale, SpriteEffects.None, 0f);

• have you called spriteBatch.begin() and spriteBatch.end()? Jul 13 '12 at 9:58

The third parameter specifies which parts of the sprite you wish to draw.

From MSDN:

sourceRectangleType: Rectangle?

A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture.

You should change your code to something like this:

  spriteBatch.Draw(texture, position, new Rectangle(0, 0, (int)texture.Width, (int)texture.Height), Color.White, rotation, orgin, scale, SpriteEffects.None, 0f);


This parameter is useful if you're using spritesheets (image files with multiple sprites in them).

• Thanks! It works! But while I searched the net, I found some info about problems with collsion detection if the object i rotation? Is the rectangle also rotation? All my objects a like a square with equal width and height, will this not work? Jul 13 '12 at 10:18
• Well, that's a whole different question. It really depends on how you manage your collisions. This Rectangle is independent from the sprite's MinimalBoundingRectangle. If you have problems regarding rotation, collision detection and MBR's, then use the search. Jul 13 '12 at 10:46