如何设置 CGPathCreateWithEllipseInRect 描述的路径的起点(或起始角度)?

how to set starting point (or starting angle) of a path described by CGPathCreateWithEllipseInRect?

我有一个精灵遵循 CGPathCreateWithEllipseInRect 描述的路径。它总是从最右边的点开始(我猜是因为默认是从角度 = 0 开始)。我如何让它从最高点开始(角度 = π/2)?我现在的代码是这样的:

    let pathCenter = CGPoint(x: frame.width/2 , y: frame.height/2)
    let pathDiameter = CGFloat(frame.height/4)
    let path = CGPathCreateWithEllipseInRect(CGRect(origin: pathCenter, size: CGSize(width: pathDiameter * 1.5, height: pathDiameter * 0.8)), nil)
    let followPath = SKAction.followPath(path, asOffset: false, orientToPath: false, duration: 6.0)
    sprite.runAction(SKAction.repeatActionForever(followPath))

您必须绘制自己的路径而不是使用 CGPathCreateWithEllipseInRect,添加点的顺序与您希望精灵开始的位置相对应。

试试这个post中的方法:How to draw a circle starting at the top,然后根据需要修改。

@PatrickLynch ...谢谢我能够让我的精灵从圆形路径的最顶端开始,就像这样...
var path = CGPathCreateMutable() CGPathAddArc(path!, nil, 100, 100, 100, CGFloat(M_PI_2) , CGFloat(2*M_PI + M_PI_2) , false) var followArc = SKAction.followPath(path, asOffset: true, orientToPath: false, duration: 2.0) sprite.runAction(followArc)