我正在研究如何最好地圆角CGPathRef
上的角落,以便当我打电话SKAction
-followPath:asOffset:orientToPath:duration:
我的僵尸能够平滑地在各个角落进行动画,而不是每次抓住90个角时抓住角落。网上似乎有一些解决方案(和SO)使用Catmull-Rom样条线,我熟悉使用三维动画。使用SKAction平滑路径角落followPath
我的问题:是否有人知道一个简单的方法来添加圆角,实现Catmull-Rom似乎有点超过我需要的顶部。
其次:如果确实需要是的Catmull-ROM是怎么easy.hard获得最终曲线回一个CGPathRef
,所以我可以喂到我的SKAction
?
注意:该路径是由一个简单的A *实现生成的,该实现存储了许多CGPoint [x,y]路标,然后我想用它作为路径的基础。如果可能,我不想使用贝塞尔曲线,因为我想让新路径接近瓦片中心线以避免可碰撞物体。当我几乎需要用我的初始路径逼近时,我也不想开始计算船体的ctrl点。
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, [[[self pathArray] firstObject] position].x, [[[self pathArray] firstObject] position].y);
[[self pathArray]enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if(idx != 0) {
CGPathAddLineToPoint(path, NULL, [obj position].x, [obj position].y);
}
}];
SKAction *pathAction = [SKAction followPath:path asOffset:NO orientToPath:YES duration:[[self pathArray] count]/2];
[[self zombie] runAction:pathAction];
您可以尝试添加[arcs](https://developer.apple.com/library/ios/documentation/graphicsimaging/Reference/CGContext/Reference/reference.html#//apple_ref/c/func/CGContextAddArc)你的路径改变方向。 –