Time for action – shooting the arrow

Here is the fun part. We're going to shoot the arrow:

  1. Open the Hunter.h header file and add the following method declaration after the aimAtPoint: method declaration:
    -(CCSprite*)shootAtPoint:(CGPoint)point;
  2. Then, open the Hunter.m file and add the following implementation part of this method:
    -(CCSprite*)shootAtPoint:(CGPoint)point { //1 [self aimAtPoint:point]; //2 CCSprite *arrow = [CCSprite spriteWithImageNamed:@"arrow.png"]; //3 arrow.anchorPoint = ccp(0, 0.5f); //4 CGPoint torsoCenterGlobal = [self torsoCenterInWorldCoordinates]; arrow.position = torsoCenterGlobal; arrow.rotation = _torso.rotation; //5 [self.parent addChild:arrow]; //6 CGSize viewSize = [CCDirector sharedDirector].viewSize; CGPoint forwardVector ...

Get Learning iPhone Game Development with Cocos2D 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.