Time for action – toggling sound and music

It is a common task in many games to provide the ON and OFF switch. The most common scenario that I always come across is turning sound and music on and off. We are going to use the same CCButton class to add buttons to the MenuScene class to allow a user to turn the sound and music on and off. To do this, perform the following steps:

  1. Create the group named SoundButtons in the Resources group. Then, open the book supporting files at Chapter_09/Assets/SoundButtons and add the button images to that newly created group.
  2. Open the AudioManager.h file and add the following two properties that we'll use to check if the sound and music is enabled, and set the initial state of the buttons as follows:
    @property (nonatomic, ...

Get Learning iPhone Game Development with Cocos2D 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.