SpriteBatch.Begin Method (SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, Matrix)

Begins a sprite batch operation using the specified sort, blend, sampler, depth stencil, rasterizer state objects, plus a custom effect and a 2D transformation matrix. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default SpriteBatch Class shader.

Syntax

'Declaration
Public Sub Begin ( _
         sortMode As SpriteSortMode, _
         blendState As BlendState, _
         samplerState As SamplerState, _
         depthStencilState As DepthStencilState, _
         rasterizerState As RasterizerState, _
         effect As Effect, _
         transformMatrix As Matrix _
)
public void Begin (
         SpriteSortMode sortMode,
         BlendState blendState,
         SamplerState samplerState,
         DepthStencilState depthStencilState,
         RasterizerState rasterizerState,
         Effect effect,
         Matrix transformMatrix
)
public:
void Begin(
         SpriteSortMode sortMode,
         BlendState blendState,
         SamplerState samplerState,
         DepthStencilState depthStencilState,
         RasterizerState rasterizerState,
         Effect effect,
         Matrix transformMatrix
)

Parameters

  • sortMode
    Type: SpriteSortMode
    Sprite drawing order.
  • blendState
    Type: BlendState
    Blending options.
  • samplerState
    Type: SamplerState
    Texture sampling options.
  • depthStencilState
    Type: DepthStencilState
    Depth and stencil options.
  • rasterizerState
    Type: RasterizerState
    Rasterization options.
  • effect
    Type: Effect
    Effect state options.
  • transformMatrix
    Type: Matrix
    Transformation matrix for scale, rotate, translate options.

Exceptions

Exception type Condition
InvalidOperationException Begin has been called before calling End after the last call to Begin. Begin cannot be called again until End has been successfully called.

Remarks

This method must be called before any calls to Draw. When all the sprites have been drawn, call End.

Requirements

Namespace: Microsoft.Xna.Framework.Graphics

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

See Also

Reference

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

Platforms

Windows Phone