Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

2. Hello Pong > Sounds

Sounds

Playing simple sound effects can be done by using System Audio Services. It is recommended that the sounds be short in duration. Here are the iOS guidelines:

  • Must be .caf, .aif, or .wav files

  • The audio data in the file must be in PCM or IMA/ADPCM (IMA4) format

  • The file’s audio duration must be less than 30 seconds

You will use this to play back three different sound files for wall collision, paddle collision, and scoring a point. I have already created a few sounds that you can integrate into the game that are available for download from http://oreilly.com/catalog/0636920018414 or at my website http://toddmoore.com/. The files are named wall.wav, paddle.wav, and score.wav. Once you have downloaded the ZIP file, decompress them, and drag them into your Xcode. When prompted, make sure the “Copy...” checkbox is selected, as shown in Figure 2-12, and click OK. The sound files are now included as part of the application bundle and you can access them from within the code.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial