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 – showing the game over scene


Use the following steps to create the game over scene:

  1. Open our Xcode project if it's not already open.

  2. Create a new Objective-C class inside the GameScenes group.

  3. Call this class GameOver it should be a subclass of Scene.

  4. Switch to the GameOver.h file.

  5. Using the following line of code, add a property called message:

    @property SPTextField *message;
  6. Using the following line of code, add another property to indicate whether the game was won:

    @property (nonatomic) BOOL gameWon;
  7. Switch to GameOver.m.

  8. Import the SceneDirector.h, Assets.h, and the World.h files, as shown in the following code:

    #import "SceneDirector.h"
    #import "Assets.h"
    #import "World.h"
  9. Add an initializer for this new scene, as shown in the following code:

    -(id) init
    {
        if ((self = [super init])) {
            
            SPImage *background = [SPImage imageWithTexture:[Assets texture:@"water.png"]];
            
            _message = [SPTextField textFieldWithWidth:Sparrow.stage.width height:Sparrow.stage...