We have created a SoundManager
that loads and unloads sound effects and music tracks from the assets folder, using the classes Android has for it—SoundPool
and MediaPlayer
—and we have learned the best use for each of them.
To play sounds we have added a GameEvent
messaging system to the GameEngine
that can be used for other purposes; this is a common mechanism for synchronizing GameObjects
.
For music we have linked pausing and resuming the music with the Activity life cycle.
We have also added the possibility of enabling and disabling sounds and music independently at any time and stored the states in a persistent storage.
At this point the GameEngine
is mostly complete. In the following chapters we are going to focus on the tools that Android provides to make the UI nicer and more compelling, improving the look and feel of the game overall.