(NOTE)Recommended Reading This section covers topics that may not have been addressed yet. To learn or review those topics, please see: Base Sprite
spritetext is a useful component for quickly adding text into a project that allows the user to easily modify the properties of the text, such as the font, size, and runtime output. As with sprite, SpriteText can be added to any existing Game Object.
Common Uses
- Scores, timers, and other HUD texts
- Title, menu and button text
Using SpriteText
Creating SpriteText
SpriteText can be made in different two ways: using the Command : CreateSpriteText or adding the SpriteText
Component to any existing Game Object. The actual font is defined by the Font resource property, and all other properties control how the font is displayed: The only differences in the objects are the values of a few properties:
SpriteText Component
Adding new Fonts
Importing and accessing different Font resource resources is arguably the most important thing to understand regarding SpriteText. Luckily, Zilch Engine makes this very simple, allowing the user to drag and drop the font into the Editor window. Alternatively, the user can use either Command : Add or click on the Add button button and select Font > IMPORT FONT
:
Resource Add Button
Adding a Font
This will open a new file explorer window where the user may select the Font or Fonts to import. Once a Font is imported into Zilch, simply select the Font resource property on the SpriteText component and choose the desired Font.
Selecting Multiple Fonts
NOTE: Zilch accepts both OpenType Font (OTF) and TrueType Font (TTF).
Changing the Text
Typing the desired text into the Text property and changing the FontSize will adjust the text on screen, but that's also a bare minimum of what SpriteText is able to do. For example, by adjusting the PixelsPerUnit property, it becomes possible to create different sized Fonts without losing any visual clarity.