Time for action – add SpriteFonts to Game1

  1. Right click on the Fonts folder in the Content project in Solution Explorer and select Add | New Item.
  2. From the Add New Item dialog, select Sprite Font.
  3. Name the font Pericles36.spritefont. After adding the font, the spritefont file will open in the editor window.
  4. In the spritefont file, change <Fontname>Kootenay</Fontname> to <Fontname>Pericles</Fontname>.
  5. Change <Size>14</Size> to <Size>36</Size>.
  6. Add the following declaration to the Game1 class:
    SpriteFont pericles36Font;
  7. Update the LoadContent() method of the Game1 class to load spritefont by adding:
    pericles36Font = Content.Load<SpriteFont>(@"Fonts\Pericles36");

What just happened?

Adding a SpriteFont to your game is very similar to adding a texture image. ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.