Skip to Main Content
Learning iPhone Game Development with Cocos2D 3.0
book

Learning iPhone Game Development with Cocos2D 3.0

by Kirill Muzykov
June 2014
Beginner to intermediate content levelBeginner to intermediate
434 pages
9h 49m
English
Packt Publishing
Content preview from Learning iPhone Game Development with Cocos2D 3.0

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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit

Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit

James Goodwill, Wesley Matlock

Publisher Resources

ISBN: 9781782160144Supplemental Content