Fading sounds and music
Taking a queue from Cocos2d actions, CocosDenshion provides a few classes for fading sounds and music. These are CDLongAudioSourceFader
and CDXPropertyModifierAction
. In this example, we will see how to fade in/out all sounds, individual sounds, and music. We will also see how to crossfade two music sources.
Getting ready
Please refer to the project RecipeCollection02 for full working code of this recipe.
How to do it...
Execute the following code:
#import "SimpleAudioEngine.h" #import "CDXPropertyModifierAction.h" @implementation Ch6_FadingSoundsAndMusic -(CCLayer*) runRecipe { //Initialize the audio engine sae = [SimpleAudioEngine ...
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.