Adding a Heads-Up Display
Learn how to add a rendering layer and render a heads-up display.
We'll cover the following...
Most games display information about the players such as their health, maybe their names, any power-ups they may have, or perhaps some other useful information. Whatever the data may be, it gets displayed on the screen, usually near the top of the main game display in what’s known as a heads-up display (HUD), which is named after military hardware that lets pilots see data about their aircraft without looking down at an instrument panel.
We need the HUD to render on top of the map, in a smaller font so that it is both easier to read and can contain more detail than we could fit on a layer with huge graphical tiles.
Adding another rendering layer
The game currently has two layers: the map
, and entities
. The HUD lives on a third layer, rendered on top of the main display. It’s helpful to use a smaller font in the HUD than what we’re using to display the game tile; with a smaller font, we can display more information without overly cluttering the screen. The layers are arranged like this: ...