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 – integrating the main menu into our game

Use the following steps to add a main menu:

  1. Add a new class called MainMenu which should be a subclass of Scene.
  2. Switch to MainMenu.m.
  3. Import Assets.h and SceneDirector.h.
  4. Add the initializer for the main menu, as shown in the following code:
    -(id) init { if ((self = [super init])) { SPImage *background = [SPImage imageWithTexture:[Assets texture:@"water.png"]]; SPTexture *shipTexture = [[Assets textureAtlas:@"ship_pirate_small_cannon.xml"] textureByName:@"ne_0001"]; SPImage *ship = [SPImage imageWithTexture:shipTexture]; ship.x = 16.0f; ship.y = (Sparrow.stage.height - ship.height) / 2; SPTexture *dialogTexture = [[Assets textureAtlas:@"ui.xml"] textureByName:@"dialog_yes"]; SPButton *buttonNewGame ...

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