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.
#import "Ch4_TopDownIsometric.h" #import "SimpleAudioEngine.h" enum { CGROUP_NON_INTERRUPTIBLE = 0 }; @interface Ch6_PositionalAudio : Ch4_TopDownIsometric /* CODE OMITTED */ @end @implementation Ch6_PositionalAudio -(CCLayer*) runRecipe { //Run our top-down isometric game recipe [super runRecipe]; //Initialize max audible range audibleRange = 20.0f; //Initialize the audio engine sae = [SimpleAudioEngine sharedEngine]; //Background music is stopped on resign and resumed on becoming active...