Game Development Reference
In-Depth Information
The
m_Text
variable holds the text and text character graphics associated with the HUD item, if any.
private BillBoardCharacterSet m_Text;
The
m_Icon
variable holds an icon associated with the HUD item, if any. A heart graphic for health
statistics is an example.
private Texture m_Icon;
The
m_HUDImage
variable stores the actual full graphic image for a HUD item. Alphanumeric
characters and graphic icons are copied to this billboard for final display on the HUD.
private BillBoard m_HUDImage;
If
m_Dirty
is true, then the
m_HUDImage
billboard must be updated, because the item has changed
value. For example, the player's score has changed.
private boolean m_Dirty = false;
If the HUD item is visible, then
m_IsVisible
is true. It is false otherwise.
private boolean m_IsVisible = true;
There are also functions to provide access to the preceding private variables from outside the
information.
The constructor for the HUDItem class is shown in Listing 6-25.
Listing 6-25. HUDItem Constructor
HUDItem(String ItemName,
int NumericalValue,
Vector3 ScreenPosition,
BillBoardCharacterSet Text,
Texture Icon,
BillBoard HUDImage)
{
m_ItemName = ItemName;
m_NumericalValue= NumericalValue;
m_ScreenPosition= ScreenPosition;
m_Text = Text;
m_Icon = Icon;
m_HUDImage= HUDImage;
}
Creating the HUD Class
Now, we need to create the actual HUD class that will represent our HUD.
The variable
MAX_HUDITEMS
holds the maximum number of items that can be in the HUD, which is
set to 10.
private int MAX_HUDITEMS = 10;