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.
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 sharedDirector]viewSize]; //Basic CCSprite - Background Image CCSprite* backgroundImage = [CCSprite spriteWithImageNamed:@"scenery.png"]; backgroundImage.position = CGPointMake(winSize.width/2, winSize.height/2); ...