In SpriteKit, the clockwise
direction is reversed for UIBezierPath
but not for CGPath
. For example, if I have
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)
}
in GameScene.didMoveToView(view: SKView)
, the first node draws a 3/4 arc with top-right missing, but the second node draws a quarter arc at top-right. The reversed "clockwise" direction in UIBezierPath
is explained in this post, but why doesn't CGPath
behave the same? Isn't UIBezierPath
just a wrapper around CGPath
?
Note: This happens to both Objective-C and Swift (so not language-specific). Did not try on Mac App with NSBezierPath
.