Game Development Reference
In-Depth Information
The m_HUDItems array holds the items for this HUD.
private HUDItem[] m_HUDItems = new HUDItem[MAX_HUDITEMS];
A blank texture consisting of a black background is held in m_BlankTexture .
private Texture m_BlankTexture;
The HUD constructor is shown in Listing 6-26. The constructor creates and loads a new blank
texture from the R.drawable.blankhud resource and assigns it to m_BlankTexture . All the slots for
HUD items are initialized with an empty item and set to invalid.
Listing 6-26. HUD Constructor
HUD(Context iContext)
{
m_BlankTexture = new Texture(iContext, R.drawable.blankhud);
String ItemName = "NONE";
int NumericalValue= 0;
Vector3 ScreenPosition= null;
BillBoardCharacterSet CharacterSet = null;
Texture Icon = null;
BillBoard HUDImage = null;
// Initialize m_HUDItems
for (int i = 0; i < MAX_HUDITEMS; i++)
{
m_HUDItems[i] = new HUDItem(ItemName, NumericalValue, ScreenPosition,
CharacterSet,Icon, HUDImage);
m_HUDItems[i].SetItemValidState(false);
}
}
The FindEmptyHUDItemSlot() function finds and returns the index of an empty HUD item slot or -1 if
no slots are available. (See Listing 6-27.)
Listing 6-27. Finding an Empty HUD Item Slot
int FindEmptyHUDItemSlot()
{
int EmptySlot = -1;
for (int i = 0; i < MAX_HUDITEMS; i++)
{
if (m_HUDItems[i].IsValid() == false)
{
return i;
}
}
return EmptySlot;
}
 
Search WWH ::




Custom Search