在SpriteKit中,clockwise
方向與UIBezierPath
相反,但不是CGPath
。舉例來說,如果我有爲什麼CGPath和UIBezierPath在SpriteKit中定義「順時針」不同?
do {
let path = CGPathCreateMutable()
CGPathAddArc(path, nil, 0, 0, 10, 0, CGFloat(M_PI_2), true)
let node = SKShapeNode(path: path)
node.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
self.addChild(node)
}
do {
let path = UIBezierPath()
path.addArcWithCenter(CGPoint(x: 0, y: 0), radius: 10, startAngle: 0, endAngle: CGFloat(M_PI_2), clockwise: true)
let node = SKShapeNode(path: path.CGPath)
node.position = CGPoint(x: self.size.width/2, y: self.size.height/2 - 100)
self.addChild(node)
}
在
GameScene.didMoveToView(view: SKView)
,第一點繪製3/4弧右上角缺失,但第二點繪製在右上四分之一圓弧。 UIBezierPath
中的逆向「順時針」方向解釋爲in this post,但爲什麼CGPath
表現不一樣?是不是UIBezierPath
只是一個包裝CGPath
?
注意:Objective-C和Swift都會發生這種情況(所以不是語言特定的)。未嘗試使用NSBezierPath
的Mac App。
謝謝。我剛剛找到了關於['UIBezierView']的參考資料(https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/BezierPaths/BezierPaths.html#//apple_ref/doc/uid/) TP40010156-CH11-SW5)和['CGPath'](https://developer.apple.com/library/mac/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_overview/dq_overview.html#//apple_ref/doc/uid/TP30001066 -CH202-CJBBAEEC)。 –