예제 #1
0
 public static TextureFont Load(XElement fontDefinition, ContentManager contentManager)
 {
     TextureFont font = new TextureFont();
     foreach (XElement entry in fontDefinition.Elements("Entry"))
         font.textures.Add(entry.Attribute("Character").Value, contentManager.Load<Texture2D>(entry.Value));
     return font;
 }
예제 #2
0
 public static void DrawString(this SpriteBatch spriteBatch, TextureFont font, string str,
     Vector2 location, Color tinting)
 {
     Vector2 currentLocation = location;
     for (int character = 0; character < str.Length; character++)
     {
         string piece = str.Substring(character, 1);
         spriteBatch.Draw(font.GetTexture(piece), currentLocation, tinting);
         currentLocation.X += font.GetTexture(piece).Width;
     }
 }
예제 #3
0
 public static void DrawString(this SpriteBatch spriteBatch, TextureFont font, string str,
     Vector2 location, Color tinting, float opacity)
 {
     spriteBatch.DrawString(font, str, location, new Color(tinting, opacity));
 }