Book Image

Learning iPhone Game Development with Cocos2D 3.0

By : Kirill Muzykov
Book Image

Learning iPhone Game Development with Cocos2D 3.0

By: Kirill Muzykov

Overview of this book

Table of Contents (19 chapters)
Learning iPhone Game Development with Cocos2D 3.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – preloading sound effects


Sound effects are typically much smaller than music files, and using formats such as Core Audio Format (CAF) will decrease the time used to decode the on-disk file into memory and prepare it for playing.

Note

Remember that sound effects are decoded and played on CPU, so we should avoid using too many heavily compressed formats such as MP3 for sound effects. This is why I mention different formats such as CAF. Such formats take more space on the disk, but are easier to decode. Of course, for a simple game like ours, we don't have to worry about this.

However, if you want to make sure that there is no delay when the sound effect is played for the first time, you need to preload it. Let's perform the following steps:

  1. Open the AudioManager.h file and add the following #define statements at the top, right above the @interface declaration as follows:

    #define kSoundArrowShot @"arrow_shot.wav"
    #define kSoundBirdHit   @"bird_hit.mp3"
    #define kSoundWin       ...