Building a sound engine
This is a bit different from how we have previously handled the sound but still should seem familiar. We will be writing code that prepares a SoundPool instance and plays some sound. It will be nearly identical to the sound code we have written in the other projects with the exception that there will be a method that plays each sound effect.
This means that any part of our code that has an instance of SoundEngine will be able to play whatever sound effect it needs, yet at the same time, all the sound code will be encapsulated.
Important note
We have already seen in the GameState class that the loseLife method receives an instance of SoundEngine and calls the playPlayerExplode method.
Adding the sound files to the project
Before we get to the code, let's add the actual sound files to the project. You can find all the files in the assets folder of the Chapter 18 folder on the GitHub repo. Copy the entire assets folder, then using your operating...