Chapter 5. Audio

The topics covered in this chapter are:

  • Adding background music
  • Adding audio effects
  • Adding a mute button
  • Adding a volume slider
  • Adding a pause and resume button

Introduction

Although widely overlooked and mostly added as an afterthought to a game, audio is very crucial for the feel of a game. A good game soundtrack can enhance the game without any additional bells and whistles.

With Cocos2d, adding audio, such as background music or sound effects in your application or game, is very easy. Usually in games, there are two kinds of audio file that are used. The first one is the background music, which is played at the start of the game and usually continues to be played throughout the game. Background music is a piece of music that may be 30 seconds to a couple of minutes long that is looped an infinite number of times. The second type of audio file is the effects, which are short clips of audio that could last for a couple of milliseconds and are used for button presses and other audio cues in games.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.85.135