Table of Contents

Class SpriteBatchExtensions

Namespace
MLEM.Extended.Graphics
Assembly
MLEM.Extended.dll

A set of extension methods for dealing with Microsoft.Xna.Framework.Graphics.SpriteBatch and MonoGame.Extended.RectangleF in combination.

public static class SpriteBatchExtensions
Inheritance
SpriteBatchExtensions
Inherited Members

Methods

Draw(SpriteBatch, Texture2D, RectangleF, Color)

Submit a sprite for drawing in the current batch.

public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color)

Parameters

batch SpriteBatch

The sprite batch to draw with.

texture Texture2D

A texture.

destinationRectangle RectangleF

The drawing bounds on screen.

color Color

A color mask.

Draw(SpriteBatch, Texture2D, RectangleF, Rectangle?, Color)

Submit a sprite for drawing in the current batch.

public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color)

Parameters

batch SpriteBatch

The sprite batch to draw with.

texture Texture2D

A texture.

destinationRectangle RectangleF

The drawing bounds on screen.

sourceRectangle Rectangle?

An optional region on the texture which will be rendered. If null - draws full texture.

color Color

A color mask.

Draw(SpriteBatch, Texture2D, RectangleF, Rectangle?, Color, float, Vector2, SpriteEffects, float)

Submit a sprite for drawing in the current batch.

public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth)

Parameters

batch SpriteBatch

The sprite batch to draw with.

texture Texture2D

A texture.

destinationRectangle RectangleF

The drawing bounds on screen.

sourceRectangle Rectangle?

An optional region on the texture which will be rendered. If null - draws full texture.

color Color

A color mask.

rotation float

A rotation of this sprite.

origin Vector2

Center of the rotation. 0,0 by default.

effects SpriteEffects

Modificators for drawing. Can be combined.

layerDepth float

A depth of the layer of this sprite.

DrawGrid(SpriteBatch, Vector2, Vector2, Point, Color, float)

Draws a grid of tile outlines reminiscent of graph paper.

public static void DrawGrid(this SpriteBatch batch, Vector2 start, Vector2 tileSize, Point tileCount, Color gridColor, float gridThickness = 1)

Parameters

batch SpriteBatch

The sprite batch to draw with

start Vector2

The top left coordinate of the grid

tileSize Vector2

The size of each tile

tileCount Point

The amount of tiles in the x and y axes

gridColor Color

The color to draw the grid outlines in

gridThickness float

The thickness of each grid line. Defaults to 1.