O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding background and sound effects

After understanding some ways of integrating audio in the app, the most commonly used and easiest way is AVAudioPlayer. Basically, in this recipe, we will be adding background music, which will be running forever, and some sound effects on specific events where the user's attention is required or where the user has to be notified of some change. This adding of background music and sound effects will be done in our game FlyingSpaceship built in the previous chapters.

Getting ready

Before starting with the addition of background music and sound effects on some events, we should have a good understanding of the AVAudioPlayer class and the AVFoundation framework. So the prerequisite for this section is to have knowledge ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required