Game Development Reference
In-Depth Information
The m_ZmaxBoundary and m_ZminBoundary variables hold the maximum and minimum boundaries of
the game arena along the z axis.
private float m_ZMaxBoundary = 1;
private float m_ZMinBoundary = 0;
The m_HitGroundSFXIndex variable holds the handle to the sound effect played, if any, when the
arena object hits the ground.
private int m_HitGroundSFXIndex = -1;
The m_ExplosionSFXIndex variable holds the handle to the sound effect played when the arena object
explodes.
private int m_ExplosionSFXIndex = -1;
The ArenaObject3d constructor calls the constructor of the Object3d class and then sets the game
arena boundaries for this arena object. (See Listing 8-1.)
Listing 8-1. ArenaObject3d Constructor
ArenaObject3d(Context iContext, Mesh iMesh, MeshEx iMeshEx, Texture[] iTextures, Material iMaterial,
Shader iShader, float XMaxBoundary,float XMinBoundary,float ZMaxBoundary,float ZMinBoundary)
{
super(iContext, iMesh, iMeshEx, iTextures, iMaterial, iShader);
m_XMaxBoundary = XMaxBoundary;
m_XMinBoundary = XMinBoundary;
m_ZMaxBoundary = ZMaxBoundary;
m_ZMinBoundary = ZMinBoundary;
}
The CreateExplosionSFX() creates a new explosion sound effect by calling the AddSound() function
in the Object3d class with the resource id of the sound to create and the sound pool to hold it in.
The index to the newly created sound is held in m_ExplosionSFXIndex . (See Listing 8-2.)
Listing 8-2. Creating the Explosion Sound Effect
void CreateExplosionSFX(SoundPool Pool, int ResourceID)
{
m_ExplosionSFXIndex = AddSound(Pool, ResourceID);
}
The PlayExplosionSFX() function plays the sound effect for an explosion, if there is one, by calling
the PlaySound() function in the Object3d class with the index of the explosion sound effect.
(See Listing 8-3.)
 
Search WWH ::




Custom Search