示例#1
0
        private void DrawString(SpriteFontBase font, string text, int y, Color color, Color boxColor, Vector2 scale)
        {
            var size = font.MeasureString(text, scale);

            _spriteBatch.Draw(
                _white,
                new Rectangle(
                    0,
                    y,
                    (int)size.X,
                    (int)size.Y),
                boxColor);

            font.DrawText(_spriteBatch, text, new Vector2(0, y), color, scale);
        }
 /// <summary>
 /// Draws a text
 /// </summary>
 /// <param name="batch">A SpriteBatch.</param>
 /// <param name="text">The text which will be drawn.</param>
 /// <param name="position">The drawing location on screen.</param>
 /// <param name="colors">Colors of glyphs.</param>
 /// <param name="layerDepth">A depth of the layer of this string.</param>
 public static float DrawString(this SpriteBatch batch, SpriteFontBase font, string text, Vector2 position, Color[] colors, float layerDepth = 0.0f)
 {
     return(font.DrawText(batch, text, position, colors, layerDepth));
 }
 /// <summary>
 /// Draws a text
 /// </summary>
 /// <param name="batch">A SpriteBatch.</param>
 /// <param name="text">The text which will be drawn.</param>
 /// <param name="position">The drawing location on screen.</param>
 /// <param name="color">A color mask.</param>
 /// <param name="rotation">A rotation of this text in radians.</param>
 /// <param name="origin">Center of the rotation.</param>
 /// <param name="scale">A scaling of this text.</param>
 /// <param name="layerDepth">A depth of the layer of this string.</param>
 public static float DrawString(this SpriteBatch batch, SpriteFontBase font, string text, Vector2 position, Color color, Vector2 scale, float rotation, Vector2 origin, float layerDepth = 0.0f)
 {
     return(font.DrawText(batch, text, position, color, scale, rotation, origin, layerDepth));
 }