June 2014
Beginner to intermediate
434 pages
9h 49m
English
To make the arrow hit the bird, we need to check that the arrow and the bird are intersecting. After we have found an intersection, we need to remove the bird and the arrow. Let's add the code to perform this:
Bird.h file and add the following method declaration:-(void)removeBird:(BOOL)hitByArrow;
Bird.m file and add its implementation:-(void)removeBird:(BOOL)hitByArrow
{
if (hitByArrow)
{
CCLOG(@"Bird hit by arrow");
}
else
{
CCLOG(@"Bird flew away");
}
[self removeFromParentAndCleanup:YES];
}GameScene.m file and add the _arrows array instance variable as follows:@implementation GameScene
{
//..skipped..
NSMutableArray *_arrows;
}init method and ...