Game Development Reference
In-Depth Information
Chapter
11
Audio and Labels
In this chapter, you will learn how to play audio, both sound effects and music. Sound ef-
fects can be played via the Timeline, but most of it will have to be programmed using Ob-
jectAL, the audio engine used by Cocos2D and SpriteBuilder.
The second half of the chapter is dedicated to labels—specifically, TrueType font effects as
well as why and how to use bitmap font labels. You will also find an introduction on local-
izing label texts, and how to ensure a localized label can be changed to embed numeric in-
formation at runtime, such as score and other counters.
Introducing ObjectAL
Cocos2D includes the ObjectAL audio framework to play back sound effects and music.
ObjectAL is a framework built around the low-level OpenAL API, which is best used for
short sound effects (.wav, .caf, .aiff), and Apple's AVAudioPlayer, which is best used to de-
code and stream long-running audio (mp3, m4a, mp4, ac3). The architecture is depicted in
Figure 11-1 .
Figure 11-1 . The architecture of ObjectAL encapsulates both OpenAL and AVAudioPlayer frameworks
The OALSimpleAudio singleton provides a simple-to-use programming interface for all
essential audio needs. It generally knows of two types of audio: effects for short, memory-
buffered sound effects, and bg (background) for long-running audio like music and speech.
Search WWH ::




Custom Search