Background ambient sound is good, but not for our kind of game. What we really need is some music. Let's add the code to play the music, and as we don't want one song playing over and over again, we're going to implement switching between the tracks by performing the following steps:
First of all, we will need some music. Create the group called
Music
in theResources
group. Then, open the book's supporting files available atChapter_08/Assets/Music
and add all the music files into this group.Open the
AudioManager.h
file and import a module using the following@import
directive:@import AVFoundation.AVAudioPlayer;
Then, make the
AudioManager
class...