O'Reilly logo

Learning iPhone Game Development with Cocos2D 3.0 by Kirill Muzykov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – adding the AudioManager class

We are going to create a simple singleton class and put all the code related to the audio playback into it.

Note

Although we could play any sound effect with just a single line of code by using OALSimpleAudio, we are going to create a special class called AudioManager. This will allow us to keep the audio playback code separate from the rest of our code.

This is a good idea as it allows you to tweak the playback in one place and even switch to some other audio framework without going through all the code and searching and replacing the code. It also decentralizes the access to the audio playback, which means the main screen, game screen, and cut scenes can all control audio.

We will start from almost ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required