Book Image

Mastering Cocos2d Game Development

By : Alex Ogorek
Book Image

Mastering Cocos2d Game Development

By: Alex Ogorek

Overview of this book

Table of Contents (15 chapters)
Mastering Cocos2d Game Development
About the Author
About the Reviewers

Turning sounds on and off

Right now, we have sound effects and music playing all the time no matter what. Even though you might be someone who enjoys listening to sounds or music, when you design your games (as it's definitely an element that increases user engagement), you would want to be open to the fact that people just don't like to hear any sound at times. Thus, we must give them the option to turn the sound on and off.

No options or settings? Main menu it is!

Since we don't have a pause screen, options, settings, or anything similar, we're going to add the buttons to turn the sound on and off to the main menu. This means that a lot less code is required to add the buttons, instead of creating an entirely new scene exclusively for them. This arrangement also stays consistent with the clean feel of the game.


If you want to make a pause screen and add these two buttons to it, then go ahead by all means. The code, however, will be slightly different from what will be described here because...