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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access