Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawString C# (CSharp) Method

DrawString() public method

Submit a text string of sprites for drawing in the current batch.
public DrawString ( SpriteFont spriteFont, StringBuilder text, System.Vector2 position, System.Color color ) : void
spriteFont 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
		public void DrawString (SpriteFont spriteFont, StringBuilder text, Vector2 position, Color color)
		{
            CheckValid(spriteFont, text);

            var source = new SpriteFont.CharacterSource(text);
			spriteFont.DrawInto(this, ref source, position, color, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
		}

Same methods

SpriteBatch::DrawString ( SpriteFont spriteFont, StringBuilder text, System.Vector2 position, System.Color color, float rotation, System.Vector2 origin, System.Vector2 scale, SpriteEffects effects, float layerDepth ) : void
SpriteBatch::DrawString ( SpriteFont spriteFont, StringBuilder text, System.Vector2 position, System.Color color, float rotation, System.Vector2 origin, float scale, SpriteEffects effects, float layerDepth ) : void
SpriteBatch::DrawString ( SpriteFont spriteFont, string text, System.Vector2 position, System.Color color ) : void
SpriteBatch::DrawString ( SpriteFont spriteFont, string text, System.Vector2 position, System.Color color, float rotation, System.Vector2 origin, System.Vector2 scale, SpriteEffects effects, float layerDepth ) : void
SpriteBatch::DrawString ( SpriteFont spriteFont, string text, System.Vector2 position, System.Color color, float rotation, System.Vector2 origin, float scale, SpriteEffects effects, float layerDepth ) : void

Usage Example

        public override void draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        {
            if (mask)
            {
                string maskVaue;

                if (value < 10)
                {
                    maskVaue = "000" + value.ToString();
                }
                else if (value < 100)
                {
                    maskVaue = "00" + value.ToString();
                }
                else if (value < 1000)
                {
                    maskVaue = "0" + value.ToString();
                }
                else
                {
                    maskVaue = value.ToString();
                }

                spriteBatch.DrawString(font, maskVaue, position, Color.White, 0, new Vector2(), fontSize, SpriteEffects.None, 0f);
            }
            else
            {
                spriteBatch.DrawString(font, value.ToString(), position, Color.White, 0, new Vector2(), fontSize, SpriteEffects.None, 0f);
            }
        }
All Usage Examples Of Microsoft.Xna.Framework.Graphics.SpriteBatch::DrawString