为什么我的SKShapeNode被反转?

时间:2017-02-05 23:03:54

标签: swift sprite-kit 2d

我正在训练我的SpritKit技能,但我无法弄清楚为什么我的SKShapeNode被“逆转”,我想我错过了什么。

我正在尝试这个问题的例子:Question

所以,我尝试了2个圆角的例子,另一个例子是半圆。

我不明白为什么弯曲的两个角不是UIBezierPath对象上指定的角。

class GameScene: SKScene {

override func didMove(to view: SKView) {
    let rectangle = CGRect(x: 0, y: 0, width: 400, height: 400)
    let path = UIBezierPath(roundedRect: rectangle, byRoundingCorners: [.topLeft, .bottomRight], cornerRadii: CGSize(width: 50, height: 50))

    let shape = SKShapeNode(path: path.cgPath, centered: true)
    shape.lineWidth = 3

    addChild(shape)
}

}

enter image description here

为什么,我的半圈也没有朝着好的方向发展。

在文档中 - Apple documentation - 它说:

  

例如,指定0弧度的起始角度,π弧度的结束角度,以及将顺时针参数设置为true将绘制圆的下半部分。

class GameScene: SKScene {

override func didMove(to view: SKView) {
    let path = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: 200, startAngle: 0, endAngle: CGFloat(M_PI), clockwise: true)
    let shape = SKShapeNode(path: path.cgPath, centered: true)
    shape.lineWidth = 3

    addChild(shape)
}

}

enter image description here

最后,有人可以解释一下'角落'是如何被视为面具的吗?

0 个答案:

没有答案