C# 클래스 GameEngine.Extensions.SpriteBatchExtensions

파일 보기 프로젝트 열기: MichaelAquilina/Some-2D-RPG

공개 메소드들

메소드 설명
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