Описание тега spritebatch
SpriteBatch is a commonly used object for drawing 2D bitmaps in XNA. It allows developers to draw a sprite in their XNA Application, with a variety of options. It is included in Microsoft.Xna.Framework.Graphics
To start, you must initialize a SpriteBatch:
SpriteBatch batch1 = new SpriteBatch();
Now you can use batch1
. To begin the SpriteBatch, call SpriteBatch.Begin()
in your Draw method. Advanced users can add arguments as seen here.
Then you can draw a sprite with with the Draw(..)
method.
SpriteBatch.Draw(Texture2D, Rectangle, Color);
That is the simplest of the SpriteBatch.Draw method, you can use other arguments such as Vector2
for position, and SpriteEffects
.
You can also draw text using SpriteFonts
and the appropriate overload: SpriteBatch.DrawString (SpriteFont, String, Vector2, Color)
To end the SpriteBatch simply call SpriteBatch.End();
For more information, see the MSDN documentation for SpriteBatch.