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.
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.