O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

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

Adding a mute button

In the majority of games, you will see a mute button, which mutes the audio of the game. This is a good feature to add so that the player has the option to enjoy your game without disturbing others around them.

Getting ready

Let's create OptionsScene so that we can add the mute functionality to the game.

Create a new class called OptionsScene and make CCNode the parent class. The OptionsScene.h file will look similar to the following:

#import "CCNode.h"

@interface OptionsScene : CCNode

+(CCScene*)scene;


@end

The OptionsScene.m file will be similar to the following:

#import "OptionsScene.h" @implementation OptionsScene +(CCScene*)scene{ return[[self alloc]init]; } -(id)init{ if(self = [super init]){ CGSize winSize = [[CCDirector ...

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