I am creating a game where where you complete shapes and the area gets filled in. However, if there is an enemy bird within your shape, it will not fill in. I want to make it so that if you do trap a bird within your shape, you will lose a life. How can I write an if statement that pretty much says if the below code doesn’t take place, then you lose a life. If it helps losing a life is called doDie in my code.
-(void)fillMutablePath{
CGPoint movePoint = CGPointFromString([pointsToFillArray objectAtIndex:0]);
CGPathMoveToPoint(fillPath, NULL, movePoint.x, movePoint.y);
for (int i=0; i<[pointsToFillArray count]; i++) {
CGPoint tempPoint = CGPointFromString([pointsToFillArray objectAtIndex:i]);
CGPathAddLineToPoint(fillPath, NULL, tempPoint.x, tempPoint.y);
}
CGContextAddPath(gameViewObj._myContext, fillPath);
CGContextFillPath(gameViewObj._myContext);
CGPathRelease(fillPath);
[pointsToFillArray removeAllObjects];
}
if(fillMutablePath doesn't take place when making a shape){
[self doDie];
}
Like i said above, the reason fillMutablePath wouldn’t take place is because a bird would be trapped within the shape. Any help would be much appreciated!!
I’m not entirely sure how and where you check if the bird is in the path. I think that right before filling you path you should do (see that if-else):
If the bird is in the path die. Else, draw.
Edit after the clarification: