Export (0) Print
Expand All

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

Adds a sprite to the batch of sprites to be rendered, specifying the texture, screen position, source rectangle, color tint, rotation, origin, scale, effects, and sort depth.

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

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

Parameters

texture
The sprite texture.
position
The location, in screen coordinates, where the sprite will be drawn.
sourceRectangle
A rectangle specifying, in texels, which section of the rectangle to draw. Use null to draw the entire texture.
color
The color channel modulation to use. Use Color.White for full color with no tinting.
rotation
The angle, in radians, to rotate the sprite around the origin.
origin
The origin of the sprite. Specify (0,0) for the upper-left corner.
scale
Vector containing separate scalar multiples for the x- and y-axes of the sprite.
effects
Rotations to apply before rendering.
layerDepth

The sorting depth of the sprite, between 0 (front) and 1 (back).

You must specify either SpriteSortMode.FrontToBack or SpriteSortMode.BackToFront for this parameter to affect sprite 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.

Xbox 360, Windows XP SP2, Windows Vista, Zune

Community Additions

ADD
Show:
© 2014 Microsoft