Sdílet prostřednictvím


SpriteBatch.Begin Method (SpriteBlendMode, SpriteSortMode, SaveStateMode)

Prepares the graphics device for drawing sprites with specified blending, sorting, and render state options.

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

Syntax

public void Begin (
         SpriteBlendMode blendMode,
         SpriteSortMode sortMode,
         SaveStateMode stateMode
)

Parameters

  • blendMode
    Blending options to use when rendering.
  • sortMode
    Sorting options to use when rendering.
  • stateMode
    Rendering state 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.

Begin sets the following render states:

Begin sets the following sampler states:

If Begin is called with SaveStateMode set to None, the caller must reset these states must be reset if they are used elsewhere. Calling Begin with SaveStateMode set to SaveState will reset these values properly, but performance may be adversely affected.

See Also

Tasks

How to: Draw a Sprite

Concepts

2D Graphics Overview

Reference

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

Platforms

Xbox 360, Windows XP SP2, Windows Vista