Time for action – add SpriteFonts to Game1
- Right click on the
Fonts
folder in the Content project in Solution Explorer and select Add | New Item. - From the Add New Item dialog, select Sprite Font.
- Name the font Pericles36.spritefont. After adding the font, the
spritefont
file will open in the editor window. - In the
spritefont
file, change<Fontname>Kootenay</Fontname>
to<Fontname>Pericles</Fontname>
. - Change
<Size>14</Size>
to<Size>36</Size>
. - Add the following declaration to the Game1 class:
SpriteFont pericles36Font;
- Update the
LoadContent()
method of the Game1 class to loadspritefont
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.