Game Development Reference
In-Depth Information
The
m_Active
boolean array holds true for an element if the corresponding arena object in the
m_ArenaObjectSet
is active and has to be rendered and updated.
private boolean[] m_Active = new boolean[MAX_ARENA_OBJECTS];
The
m_ExplosionMinVelocity
variable holds the minimum velocity for particles in an explosion
associated with this set of arena objects.
private float m_ExplosionMinVelocity = 0.02f;
The
m_ExplosionMaxVelocity
variable holds the maximum velocity for particles in an explosion
associated with this set of arena objects.
private float m_ExplosionMaxVelocity = 0.4f;
The
Init()
function initializes all the arena objects in this class to null, and the
m_Active
status is set
to false, which means it is inactive and not to be rendered, updated, or processed. (See Listing 10-1.)
Listing 10-1. Initializing the Arena Objects
void Init()
{
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
m_ArenaObjectSet[i] = null;
m_Active[i] = false;
}
}
The ArenaObjectSet constructor initializes the ArenaObject set by calling the
Init()
function.
(See Listing 10-2.)
Listing 10-2. The ArenaObjectSet Constructor
ArenaObjectSet(Context iContext)
{
m_Context = iContext;
Init();
}
The
SaveSet()
function saves the data for the ArenaObject set. (See Listing 10-3.)
The
SaveSet()
function does the following:
1.
Retrieves a SharedPreferences object for the input parameter Handle by
calling the
getSharedPreferences()
function
Retrieves an Editor object by calling
edit()
on the SharedPreferences object
from Step 1
2.
Saves the values of the
m_Active
array to the shared preferences by creating
a unique handle consisting of the input parameter Handle, the “Active”
keyword, and the index i
3.