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 – adding a tutorial to our intro scene


Follow these steps to display hints during the intro:

  1. In Intro.h, add an instance variable called message:

    SPTextField *_message;
  2. Switch to Intro.m.

  3. Update the initializer with the help of the following code:

    [buttonNext addEventListenerForType:SP_EVENT_TYPE_TRIGGERED block:^(id event) {
      [(SceneDirector *) self.director showScene:@"piratecove"];
    }];
    
    SPQuad *quad = [SPQuad quadWithWidth:400.0f height:60.0f color:SP_BLACK];
    quad.alpha = 0.8f;
    quad.x = 16.0f;
    quad.y = 16.0f;
    
    _message = [SPTextField textFieldWithWidth:400.0f height:60.0f text:@"Welcome to the battlefield."];
    _message.color = SP_WHITE;
    _message.x = 16.0f;
    _message.y = 16.0f;
    
    [self addChild:background];
    [self addChild:_pirateShip];
    [self addChild:_enemyShip];
    [self addChild:buttonNext];
    [self addChild:quad];
    [self addChild:_message];
    
  4. Update the reset method, as shown in the following code:

    [_pirateShip moveToX:Sparrow.stage.width / 2 andY:(Sparrow.stage.height / 2) - 20.0f...