tags:

views:

531

answers:

3

Duplicate:

use more then one sound in my iphone application using cocos2d

Hi, All of the member of this forums.I need to help yours for doing my game project.I want to play some sound in my gaming project.When this game is started a background sound is playing continuously until the game is stop (exit). When game is played that time some action button are work and every action one sound is play for few second but background sound did not stop that time. How can i do this if anyone have a solution than reply with answer please.

A: 

You could, if you implemented your own mixer. Just playback a buffer and mix the audio yourself. It' basically boils down to just averaging two different amplitudes. In some cases it's a bit more advanced.

John Leidegren
A: 

Check out the AVAudioPlayer class. It will do what you need.

One thing to be aware of is that this class will only play one mp3 format sound at one time. I suggest converting to IMA4 format if you are using mp3 and need to play multiple sounds at once.

You can use the afconvert command to convert between sound file formats.

AVAudioPlayer is available in firmware 2.2+.

Dana Holt
+1  A: 

If you are using cocos2d 0.82, then you can use denshion for this.

Play background music: [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"somemusic.mp3"];

Play SOUND EFFECT: [[SimpleAudioEngine sharedEngine] playEffect:@"mysound.wav"]

You can find this and more at http://www.cocos2d-iphone.org/wiki/doku.php/cocosdenshion%3Acookbook

Matt Williamson