Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Time for action – managing our scenes with a scene director


To create the scene director, take a look at the following steps:

  1. Create a new Objective-C class called SceneDirector, which is derived from the SPSprite class, and save it in the Scene group.

  2. Add an instance variable called _dict, which is an NSMutableDictionary type.

  3. Add an instance method that will add a scene to the scene director, as shown in the following code:

    -(void) addScene:(Scene *)scene;
  4. 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;
  5. 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;
  6. Let's switch to the implementation. The initializer should initialize the _dict variable.

  7. Implement the addScene:(Scene *)scene withName:(NSString *)name method with the following piece of code:

    -(void) addScene:(Scene...