在我的游戏中,我有一个SKShapeNode根据另一个节点的位置进行更新。
直到有一天它开始出现这样的故障时,它一直按预期工作。
Example(抱歉质量很差)
不确定是什么原因导致这个故障。这可能与iOS 7.1更新有关吗?
这是我绘制拖拉机横梁的代码。它被称为每次更新。 SKShapeNode梁是我的Ship类的属性,以下方法更新它应该绘制的路径。
-(void)drawTractorBeam{
if (self.hasAnimal) {
CGPoint topLeftCow = CGPointMake(self.animal.position.x - self.animal.size.width/2, self.animal.position.y + self.animal.size.height/2);
CGPoint topRightCow = CGPointMake(self.animal.position.x + self.animal.size.width/2, self.animal.position.y + self.animal.size.height/2);
CGPoint leftBeamEnd = CGPointMake(topLeftCow.x * 100, topLeftCow.y * 100);
CGPoint rightBeamEnd = CGPointMake(topRightCow.x * 100, topRightCow.y * 100);
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, -10, 0);
CGPathAddLineToPoint(path, NULL, leftBeamEnd.x, leftBeamEnd.y);
CGPathAddLineToPoint(path, NULL, rightBeamEnd.x, rightBeamEnd.y);
CGPathAddLineToPoint(path, NULL, 10, 0);
CGPathAddLineToPoint(path, NULL, -10, 0);
self.beam.path = path;
self.beam.fillColor = [UIColor colorWithRed:0.0f green:255.0f blue:0.0f alpha:0.3f];
}else{
self.beam.path = nil;
}
}