public DrawString ( |
||
spriteFont | A font. | |
text | StringBuilder | The text which will be drawn. |
position | System.Vector2 | The drawing location on screen. |
color | System.Color | A color mask. |
return | void |
string text = "Hello World!"; Vector2 position = new Vector2(100, 100); Color color = Color.White; spriteBatch.DrawString(font, text, position, color);
string text = "Line 1\nLine 2\nLine 3"; Vector2 position = new Vector2(100, 100); Color color = Color.White; spriteBatch.DrawString(font, text, position, color);This example creates a new string variable with three lines of text separated by the newline character "\n". The position and color variables are set as before. The DrawString method is then called with the font, position, text, and color as parameters to draw all three lines of text on the screen. In both examples, the font variable is assumed to have been created elsewhere in the code. The package library used is Microsoft.Xna.Framework.Graphics.
public DrawString ( |
||
spriteFont | A font. | |
text | StringBuilder | The text which will be drawn. |
position | System.Vector2 | The drawing location on screen. |
color | System.Color | A color mask. |
return | void |