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 – having the game over scene show up


To incorporate the game over scene into the game, use the following steps:

  1. Switch to the Battlefield.h file.

  2. Remove both the textGameWon and textGameLost properties.

  3. Switch to the Battlefield.m file.

  4. Remove all references to the textGameWon and textGameLost properties.

  5. In the GameOver.m file, add a reset method using the following code:

    -(void) reset
    {
        self.gameWon = NO;
    }
  6. In the SceneDirector.h file, add a property called currentScene using the following code:

    @property (readonly) Scene *currentScene;
  7. In the SceneDirector.m file, update the showScene method to set the currentScene property, as shown in the following code:

    -(void) showScene:(NSString *)name
    {
        for (NSString* sceneName in _dict) {
            ((Scene *) _dict[sceneName]).visible = false;
            [((Scene *) _dict[sceneName]) stop];
        }
        
        if (_dict[name] != nil) {
            ((Scene *) _dict[name]).visible = YES;
            [((Scene *) _dict[name]) reset];
            _currentScene...