Game Development Reference
In-Depth Information
This displays the entire font in white on black. Change the clear color to confirm
that the transparency is working correctly. Then uncomment the line with
SetColor in it. This will turn the font black. It's easy to change the font color
using the sprite code.
To render a single character, the sprite must have its UV settings altered. Try
entering the following UV information.
_text.Texture = textureManager.Get("font");
_text.SetUVs(new Point(0.113f, 0), new Point(0.171f, 0.101f));
This will display a giant dollar sign. It will be very large because the sprite size is
still set to 256 by 256. The natural resolution of the dollar sign is 15 by 26 pixels.
Change the height and width and something like Figure 7.2 will appear.
_text.SetUVs(new Point(0.113f, 0), new Point(0.171f, 0.101f));
_text.SetWidth(15);
_text.SetHeight(26);
This UV data forms a small box around the dollar sign and allows it to be clearly
cut out, as shown in Figure 7.3. The information about the location of each
character in the texture map was generated by the Bitmap Font Program when
the texture was generated. This information can be used to get the correct UVs.
Figure 7.2
A single character.
 
Search WWH ::




Custom Search