Summary

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 ...

Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.