O'Reilly logo

Build iOS Games with Sprite Kit by Josh Smith, Jonathan Penn

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

Playing Sound Effects in the Scene

When you’re ready to implement one-shot sound effects in your game, there’s no need to reach for the iOS audio APIs. Sprite Kit gives us everything we need with a special sound action. Let’s add some shooting and explosion effects for the collisions.

First, we need to make sure the sound files are in the Xcode project. If you’re creating the project yourself on the fly, drag the obstacleExplode.m4a, shipExplode.m4a, and shoot.m4a files into the Xcode file sidebar. Make sure the SpaceRun target checkbox is checked, like in Figure 7, Dragging and dropping files into the Xcode project. Xcode doesn’t always check that box for you for some file types.

Next, we need three properties on our scene object to hold ...

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