SpriteBatch.Draw Method (Texture2D, Rectangle, Color)

Adds a sprite to a batch of sprites for rendering using the specified texture, destination rectangle, and color.

Syntax

'Declaration
Public Sub Draw ( _
         texture As Texture2D, _
         destinationRectangle As Rectangle, _
         color As Color _
)
public void Draw (
         Texture2D texture,
         Rectangle destinationRectangle,
         Color color
)
public:
void Draw(
         Texture2D texture,
         Rectangle destinationRectangle,
         Color color
)

Parameters

  • texture
    Type: Texture2D
    A texture.
  • destinationRectangle
    Type: Rectangle
    A rectangle that specifies (in screen coordinates) the destination for drawing the sprite.
  • color
    Type: Color
    The color to tint a sprite. Use Color.White for full color with no tinting.

Exceptions

Exception type Condition
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.

Remarks

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.

Requirements

Namespace: Microsoft.Xna.Framework.Graphics

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

See Also

Tasks

Drawing a Sprite

Concepts

What Is a Sprite?

Reference

SpriteBatch Class
SpriteBatch Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Windows Phone