Game Development Reference
In-Depth Information
Game audio is handled by two Java classes that encapsulate multiple media players. These audio
classes receive events from the DSO (thru JNI) when a sound event occurs and play it accordingly. Let's
look at the Java classes in more detail.
Understanding the Java Classes for Wolf 3D
We have looked at the high-level game architecture of Wolf 3D for Android. Now, let's look at the classes
that constitute the Java side. Before we get started, make sure you have imported the chapter source into
your workspace. This will greatly help your understanding of this section. Figure 6-3 shows the layout of
the Java files for the game. The most important ones follow:
WolfLauncher : This is the game's main activity class, and it is created when the
user starts the game. Its job is to display the UI, handle phone events, such as
keyboard touch events, and send them to the Natives class. It also spawns the
main thread that starts the native game loop.
SNESController : This class encapsulates the SNES-style controller used to play the
game without a keyboard.
ControllerListener : This is an interface implemented by WolfLauncher and
provides the means for listening for controller events.
AudioClip : This class encapsulates the Android media player and has methods to
play, stop, or loop a sound.
AudioMananger : This class acts as an intermediary between the main activity and
the audio clips. It has logic to load, start, and cache sounds for better
performance.
SoundNames : This class maps native sounds (represented by a number) to raw
sounds resources within the project.
Natives : This is a two-way interface with the DSO. It contains all the native
functions that will be implemented in the DSO, plus callbacks that will be started
when the DSO sends messages back to Java.
Search WWH ::




Custom Search