Unlike SimpleAudioEngine, playing sounds with CDSoundEngine requires some setting up first. We'll begin by doing that.
Generally, you will want to play sounds at the very first scene of your game and keep those sounds loaded for later use. Maybe if memory is a concern in your game, you won't want to have 30 sound files loaded into memory. For our simple game, we'll initialize CDSoundEngine in the AppDelegate
and load all the sounds in there. This is not optimal in many cases and you are free to change it, maybe loading some sounds at the beginning and many others just in scenes where you'll use them.
The first thing you want to do is to remove all the SimpleAudioEngine code that we wrote a little earlier. This will ensure that the new audio is played correctly and the audio session interruption will be handled properly.
So, we'll do all the initialization in our
AerialGunAppDelegate
class as follows:
First, CDSoundEngine requires the OpenAL and AudioToolbox frameworks...