SpriteBatch.Draw Method (Texture2D, Rectangle, Nullable<Rectangle>, Color, Single, Vector2, SpriteEffects, Single)

Adds a sprite to a batch of sprites for rendering using the specified texture, destination rectangle, source rectangle, color, rotation, origin, effects and layer.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.dll)

public void Draw (
         Texture2D texture,
         Rectangle destinationRectangle,
         Nullable<Rectangle> sourceRectangle,
         Color color,
         float rotation,
         Vector2 origin,
         SpriteEffects effects,
         float layerDepth


Type: Texture2D
A texture.
Type: Rectangle
A rectangle that specifies (in screen coordinates) the destination for drawing the sprite. If this rectangle is not the same size as the source rectangle, the sprite will be scaled to fit.
Type: Nullable<Rectangle>
A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture.
Type: Color
The color to tint a sprite. Use Color.White for full color with no tinting.
Type: Single
Specifies the angle (in radians) to rotate the sprite about its center.
Type: Vector2
The sprite origin; the default is (0,0) which represents the upper-left corner.
Type: SpriteEffects
Effects to apply.
Type: Single
The depth of a layer. By default, 0 represents the front layer and 1 represents a back layer. Use SpriteSortMode if you want sprites to be sorted during drawing.

Exception typeCondition
ArgumentNullException texture is null.
InvalidOperationException Draw was called, but Begin has not yet been called. Begin must be called successfully before you can call Draw.

Before making any calls to Draw, you must call Begin. Once all calls to Draw are complete, call End.

If you are texture wrapping with a Reach profile or texture wrapping on Windows Phone, the texture must have power of 2 dimensions.

Xbox 360, Windows 7, Windows Vista, Windows XP

Community Additions