C# Класс GameEngine.Extensions.SpriteBatchExtensions

Показать файл Открыть проект

Открытые методы

Метод Описание
DrawCenteredString ( SpriteBatch spriteBatch, SpriteFont spriteFont, string text, Vector2 position, Color color ) : void
DrawCross ( SpriteBatch spriteBatch, Vector2 center, int size, Color background, float layerDepth ) : void
DrawMultiLineString ( SpriteBatch spriteBatch, SpriteFont spriteFont, string text, int pxMaxLineLength, int padding, Vector2 position, Color color ) : void

This method takes a string and automatically attempts to fit the string within the specified max line length parameter by splitting it into multiple lines when possible. This is done by taking each token in the string that is divided by the whitespace character ' '. It is still possible for one of the lines in the string to exceed the pxMaxLineLength paramater value if a token is longer than the specified amount. A padding value is required to be passed to specify how much pixel space should be used between each line outputted. The Vector2 value passed to the function specifies the center where the string will be drawn to the screen.

DrawRectangle ( this spriteBatch, Rectangle destRectangle, Color background, float layerDepth ) : void

This can probably be vastly improved using vertices and a shader. The current method is extremely ineffecient for what its intentional purpose is. (TODO)

FillRectangle ( SpriteBatch spriteBatch, Rectangle destRectangle, Color background, float layerDepth ) : void

Описание методов

DrawCenteredString() публичный статический Метод

public static DrawCenteredString ( SpriteBatch spriteBatch, SpriteFont spriteFont, string text, Vector2 position, Color color ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
spriteFont Microsoft.Xna.Framework.Graphics.SpriteFont
text string
position Vector2
color Color
Результат void

DrawCross() публичный статический Метод

public static DrawCross ( SpriteBatch spriteBatch, Vector2 center, int size, Color background, float layerDepth ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
center Vector2
size int
background Color
layerDepth float
Результат void

DrawMultiLineString() публичный статический Метод

This method takes a string and automatically attempts to fit the string within the specified max line length parameter by splitting it into multiple lines when possible. This is done by taking each token in the string that is divided by the whitespace character ' '. It is still possible for one of the lines in the string to exceed the pxMaxLineLength paramater value if a token is longer than the specified amount. A padding value is required to be passed to specify how much pixel space should be used between each line outputted. The Vector2 value passed to the function specifies the center where the string will be drawn to the screen.
public static DrawMultiLineString ( SpriteBatch spriteBatch, SpriteFont spriteFont, string text, int pxMaxLineLength, int padding, Vector2 position, Color color ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch SpriteBatch option with which to perform the string draw operation.
spriteFont Microsoft.Xna.Framework.Graphics.SpriteFont SpriteFont instance which will be used to draw the string.
text string string message to draw to the screen and automatically split.
pxMaxLineLength int integer value specifying the ideal max possible length for each line in pixels.
padding int integer value specifying the amount of padding to use between each line in pixels.
position Vector2 Vector2 position specifying the center of where the string should be drawn.
color Color Color instance specifying the color with which to draw the text.
Результат void

DrawRectangle() публичный статический Метод

This can probably be vastly improved using vertices and a shader. The current method is extremely ineffecient for what its intentional purpose is. (TODO)
public static DrawRectangle ( this spriteBatch, Rectangle destRectangle, Color background, float layerDepth ) : void
spriteBatch this
destRectangle Microsoft.Xna.Framework.Rectangle
background Color
layerDepth float
Результат void

FillRectangle() публичный статический Метод

public static FillRectangle ( SpriteBatch spriteBatch, Rectangle destRectangle, Color background, float layerDepth ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
destRectangle Microsoft.Xna.Framework.Rectangle
background Color
layerDepth float
Результат void