cocoa-touchios4cocos2d-iphonesimpleaudioengine

Playing sound in cocos2d game


I'm checking code of a build game by another developer. You can understand how tuf it is. :)

I have to make a change in its sound.

When game is running the background sound remain same till game is over.

My task is to change sound after a specific time.

[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"background.wav" loop:TRUE];

This piece of code is used by the old developer.

I don't know how to make chnage according to my need.


Solution

  • Yea! difficult task indeed! :)

    Does a function is calling at the time you want to stop the background music? Like game paused, game over etc. In that case use this.

    [[SimpleAudioEngine sharedEngine] stopBackgroundMusic];

    After that you can change to another background or do whatever.