O'Reilly logo

Cocos2d for iPhone 1 Game Development Cookbook by Nathan Burba

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

Using positional audio in a game

To increase the realism of the sounds we use in a game, we can modify audio properties based on in-game factors. In this example, we use source distance, audible range, and object size to determine gain, pitch, and pan. We'll demonstrate this by adding sounds to the TopDownIsometric demo from Chapter 4 ,Physics.

Using positional audio in a game

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe.

How to do it...

Execute the following code:

#import "Ch4_TopDownIsometric.h" #import "SimpleAudioEngine.h" enum { CGROUP_NON_INTERRUPTIBLE = 0 }; @interface Ch6_PositionalAudio : Ch4_TopDownIsometric /* CODE OMITTED ...

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