O'Reilly logo

iOS 7 Game Development by Dmitry Volevodz

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 sound and music

Our game feels a bit bland without sound effects, so we are going to add some. We will add background music and sound effects.

Sprite Kit is mostly a graphics library, and sound support is limited, but there are ways to add music to our game.

The first thing that we need to do is add music files to the project. To do this, drag-and-drop Kick_Shock.mp3, shieldCharged.wav, and shieldSmashed.wav to our project in Xcode. Select Copy items into destination group's folder and make sure that Add to targets has your project selected.

In order to play background music, we will need to add the AVFoundation library to our project.

The AVFoundation library is a collection of classes that allows for audio and video playback on iOS devices. ...

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