Time for action – managing our scenes with a scene director
To create the scene director, take a look at the following steps:
Create a new Objective-C class called
SceneDirector
, which is derived from theSPSprite
class, and save it in the Scene group.Add an instance variable called
_dict
, which is anNSMutableDictionary
type.Add an instance method that will add a scene to the scene director, as shown in the following code:
-(void) addScene:(Scene *)scene;
Add a second instance method that will add a scene, but this time you are also able to define/overwrite the name of the scene:
-(void) addScene:(Scene *)scene withName:(NSString *)name;
Add an instance method that will show a scene and take
NSString
as its parameter, as shown in the following code:-(void) showScene:(NSString *)name;
Let's switch to the implementation. The initializer should initialize the
_dict
variable.Implement the
addScene:(Scene *)scene withName:(NSString *)name
method with the following piece of code:-(void) addScene:(Scene...