Time for action – creating our scene manager setup
To create our scene manager setup, we need to follow these steps:
Open your Xcode game template if it's not already open.
Right-click on the Classes folder and select New Group.
Rename the group to GameScenes.
Create a new Objective-C class called
PirateCove
which is sub-classed fromScene
.Add an initializer with the following content:
if ((self = [super init])) { NSLog(@"Pirate cove scene created"); }
Create another Objective-C class which is sub-classed from
Scene
. Call thisBattlefield
.Add an initializer with the following content:
-(id) init { if ((self = [super init])) { NSLog(@"Battlefield scene created"); } return self; }
Switch to the
Game.m
file.Add the
PirateCove.h
,Battlefield.h
, andSceneDirector.h
files to theimport
section, as shown in the following code:#import "SceneDirector.h" #import "PirateCove.h" #import "Battlefield.h"
In the
init
method, create an instance of thePirateCove
andBattlefield
classes...