Game Development Reference
In-Depth Information
Figure 14.4 A tooltip in action.
This is where the Tooltip class comes into play. To initialize a tooltip, you
provide the key to the localized string, the screen space position of where the
bottom-left corner of the tooltip should be, and a list of TipData . The TipData
list is what gives the Tooltip class some information on what exactly it needs
to replace the placeholder values with. This is so it knows that, for example,
{0} refers to the monetary cost of the tower. This information is what all of the
CreateTowerBuildCost and similar functions generate.
Whereitgetsabitmessyisinthe InitializeGrid functionin UIGameplay .
The grid is the series of buttons in the bottom-left part of the HUD, which are the
buttons that allow you to build all the different towers and such. Because there are
multiple grid buttons, and some complex tooltips for said grid buttons, the func-
tion to create the tooltips ends upbeing pretty long. Ifthe game had a lot more grid
buttons, it would be very impractical to initialize the buttons in this manner. This
ideally would be something that's also stored in an external data file. But for this
game, it was simpler to implement in the manner it was done.
Search WWH ::




Custom Search