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 ...

Get Learning iPhone Game Development with Cocos2D 3.0 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.