June 2014
Beginner to intermediate
434 pages
9h 49m
English
Now that we can point where to shoot, let's make the hunter to aim at this point.
Hunter.h file and add the aimAtPoint: method declaration:#import "CCSprite.h"
@interface Hunter : CCSprite
-(void)aimAtPoint:(CGPoint)point;
@endHunter.m file and add the following methods below the init method:-(CGPoint)torsoCenterInWorldCoordinates { //1 CGPoint torsoCenterLocal = ccp(_torso.contentSize.width / 2.0f, _torso.contentSize.height / 2.0f); //2 CGPoint torsoCenterWorld = [_torso convertToWorldSpace:torsoCenterLocal]; return torsoCenterWorld; } -(float)calculateTorsoRotationToLookAtPoint: (CGPoint)targetPoint { //1 CGPoint torsoCenterWorld = [self torsoCenterInWorldCoordinates]; //2 ...