我正在尝试创建一个跟随对象的路径,其形状为数字8.是否可以创建一条曲线,如数字8的形状?
如果不是,你会怎么建议我这样做?
谢谢(:
答案 0 :(得分:1)
SKPhysicsBody Path Generator是一款功能强大的工具,您可以随心所欲地创建它!
非常舒适,轻松地创造你的道路!
基本说明
答案 1 :(得分:0)
这是一个简单的例子:
var curve = UIBezierPath()
let startPoint = CGPoint(x: 100, y: 50)
curve.moveToPoint(startPoint)
// top right
curve.addCurveToPoint(CGPoint(x: 100, y: 250),
controlPoint1: CGPoint(x: 200, y: 50),
controlPoint2: CGPoint(x: 200, y: 250))
// bottom left
curve.addCurveToPoint(CGPoint(x: 100, y: 450),
controlPoint1: CGPoint(x: 0, y: 250),
controlPoint2: CGPoint(x: 0, y: 450))
// bottom right
curve.addCurveToPoint(CGPoint(x: 100, y: 250),
controlPoint1: CGPoint(x: 200, y: 450),
controlPoint2: CGPoint(x: 200, y: 250))
// top left
curve.addCurveToPoint(CGPoint(x: 100, y: 50),
controlPoint1: CGPoint(x: 0, y: 250),
controlPoint2: CGPoint(x: 0, y: 50))
curve.closePath()