我正在创建一个游戏,您可以在其中完成形状并填充该区域。但是,如果您的形状中有一只敌鸟,它就不会填充。我想这样做,如果您确实将一只鸟困在您的形状,你将失去生命。我怎么能写一个 if 语句,如果下面的代码没有发生,那么你就会失去生命。如果它有助于失去生命,在我的代码中称为 doDie。
-(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];
}
就像我上面说的,fillMutablePath 不会发生的原因是因为鸟会被困在形状中。任何帮助将非常感激!!