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 ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.