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 – implementing a scene class


To create a scene class, use the following steps:

  1. Create a new group called Scene.

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

  3. Add a property called guiLayer, which is a SPSPrite type, as shown in the following code:

    @property SPSprite* guiLayer;
  4. Add another property called name, which is an NSString, as shown in the following code:

    @property NSString* name;
  5. Add a third property called director, which is an id, as shown in the following code:

    @property id director;
  6. Add an initializer that initializes the properties of the class:

    -(id) init
    {
        if ((self = [super init])) {
            self.guiLayer = [[SPSprite alloc] init];
            self.director = nil;
            self.name = @"scene";
        }
        
        return self;
    }
  7. Add a second initializer that sets the name of the scene; this should be called initWithName:

    -(id) initWithName:(NSString *) name
    {
        self = [self init];
        self.name = name...