Adding text fields
I'm generally a big fan of having as few text fields in an application as possible, and this holds doubly true for a game but there are some occasions when receiving some sort of textual information from the player is required so in these regrettable occasions, a textbox or field may be an appropriate choice.
Unfortunately, a premade textbox isn't always available to us on any given gaming project, so sometimes we must create our own.
Getting ready
This recipe only relies upon the presence of a single SpriteFont
file referring to any font at any desired size.
How to do it...
To start adding textboxes to your own games:
1. Add a
SpriteFont
to the solution namedText:
<?xml version="1.0" encoding="utf-8"?> <XnaContent xmlns:Graphics= "Microsoft.Xna.Framework.Content.Pipeline.Graphics"> <Asset Type="Graphics:FontDescription"> <FontName>Segoe UI Mono</FontName> <Size>28</Size> <Spacing>0</Spacing> <UseKerning>true<...