Game Development Reference
In-Depth Information
The
GetMaterial()
function returns a reference to the object's material.
Material GetMaterial() {return m_Material;}
The
SetBlend()
function sets the
m_Blend
variable.
void SetBlend(boolean value) { m_Blend = value; }
The
DrawObject()
function code is added to enable blending if
m_Blend
is true and disable blending
after the object is rendered. See the code in bold in Listing 6-36.
Listing 6-36. Modifying the
DrawObject()
Function
void DrawObject(Camera Cam, PointLight light)
{
if (m_Blend)
{
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE);
}
if (m_Visible)
{
DrawObject(Cam, light, m_Orientation.GetPosition(), m_Orientation.GetRotationAxis(),
m_Orientation.GetScale());
}
if (m_Blend)
{
GLES20.glDisable(GLES20.GL_BLEND);
}
}
Drone Grid Case Study: Creating the HUD
In this section, we will create the HUD for our Drone Grid case-study game. The HUD will consist
of two HUD items. One item will be the player's score, and the other item will be the player's health.
You will need to download the Android project for this chapter, if you haven't done so already, and
install it into a new work space. The project will contain graphics for the fonts and an icon for the
player's health.
Modifying the MyGLRenderer Class
We will have to alter the MyGLRenderer class from the previous hands-on example dealing with
sound.
The
m_CharacterSetTextures
array holds the character set textures for our HUD, which consist of
letters, numbers, and extra characters.
private Texture[] m_CharacterSetTextures = new Texture[BillBoardCharacterSet.MAX_CHARACTERS];