O'Reilly logo

Sparrow iOS Game Framework Beginner's Guide by Johannes Stein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – making the pirate cove playable

To add game mechanics to the pirate cove, use the following steps:

  1. Move the line of code [SPTextField registerBitmapFontFromFile:@"PirateFont.fnt"]; from Dialog.m to the beginning of the Game.m file.
  2. Add a button in PirateCove.m, as shown in the following code:
    SPButton *buttonBattle = [SPButton buttonWithUpState:[[Assets textureAtlas:@"ui.xml"] textureByName:@"dialog_yes"]; 
    text:@"Begin battle"];
    
    buttonBattle.y = Sparrow.stage.height - buttonBattle.height - 8.0f;
    buttonBattle.x = (Sparrow.stage.width - buttonBattle.width) / 2;
    
    [buttonBattle addEventListenerForType:SP_EVENT_TYPE_TRIGGERED block:^(SPEvent *event){
      [((SceneDirector *) self.director) showScene:@"battlefield"];
    }];
  3. Add the button to the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required