Game Development Reference
In-Depth Information
Figure 11-2 . Audio file preview and settings
You can play back the audio within SpriteBuilder using the Play button. Underneath, you
see the duration expressed in seconds and an indication of whether the audio file is mono
or stereo. Below that are the publishing settings, where you can choose between CAF
format (uncompressed) for short sound effects and MP4 format (compressed) for long-
running audio. The MP4 format also allows you to change the quality setting. The lower
the quality setting is, the smaller the resulting file will be. The default audio quality set-
tings are editable in the File
Project Settings dialog.
SpriteBuilder will automatically assume an imported audio file shorter than 15 seconds is
a sound effect and will thus select the corresponding CAF format. Otherwise, it will have
MP4 preselected for you. Also note, at the time of this writing, only audio files with the
.caf and .wav extensions could be imported. If you already have files in the .mp3 or .m4a
format, you can either add them to Xcode directly or, preferably, convert them to .wav or
.caf to be able to manage them with SpriteBuilder.
Playing Sound Effects via the Timeline
In SpriteBuilder, you can add sound-effects keyframes to any Timeline. This is most use-
ful if you need to synchronize audio playback with other Timeline animations, such as the
appearance of an object or matching the moment when the moving object starts to slow
down. Timeline sound effects will be played through OALSimpleAudio 's effects chan-
nel, thus using OpenAL for playback regardless of the file format.
Caution If the node owning a Timeline's CCBAnimationManager dealloc-
ates, any sound effect played through that Timeline will be cut short (stopped)
or won't even get to play at all. This typically affects the playback of audio files
with a duration longer than the Timeline whose end has the node removed from
the sceneā€”for instance, via a Callbacks keyframe.
In SpriteBuilder, open MainMenuButtons.ccb in the UserInterface folder. The goal is to
synchronize the sound-effects playback with the appearance of the logo and buttons.
You can add Sound effects keyframes just like Callbacks keyframes by holding down the
Option key, and then left-clicking to add a keyframe. You should add a total of three
Sound effects keyframes. Place the first one near the start of the Timeline, and place the
Search WWH ::




Custom Search