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 – creating an intro for our game

Use the following steps to add the intro scene:

  1. This is as good a time as any to move the collision detection code into a separate file. Create a new group called Logic and add a class inside this group called Collision which is a subclass of NSObject.
  2. Declare this static method in the Collision class, as shown in the following code:
    +(void) checkShipCollision: (Ship *) ship1 againstShip: (Ship *) ship2 withReferenceToSprite: (SPSprite *) sprite;
  3. Inside Collision.m, implement the checkShipCollision method with the following lines of code:
    SPRectangle *enemyShipBounds = [ship1 boundsInSpace:sprite]; SPRectangle *ball1 = [ship2.cannonBallLeft boundsInSpace:sprite]; SPRectangle *ball2 = [ship2.cannonBallRight ...

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