2016-12-26 70 views
0

我創建了一個帶有添加到SKShapeNode的UIBezier路徑的圓。 圓圈顯示正常。但是當我想更新路徑時什麼也沒有發生。我一直看到我創建的相同的初始路徑。我必須調用某種更新函數才能正確更新路徑嗎?顏色變化和筆畫變化工作正常,但路徑保持不變。SKShapeNode路徑不更新

override init(texture: SKTexture?, color: UIColor, size: CGSize) { 
    shape = SKShapeNode.init() 

    endAngle = CGFloat(endAngle) * CGFloat(M_PI)/180.0 
    startAngle = CGFloat(startAngle) * CGFloat(M_PI)/180.0 

    let circlePath : UIBezierPath = UIBezierPath.init(arcCenter: CGPoint(x:0,y:0), radius: 30, startAngle: startAngle, endAngle: endAngle , clockwise: true) 

    super.init(texture: texture, color: color, size: size) 

    shape!.path = circlePath.cgPath 
    shape!.fillColor = UIColor.red 
    addChild(shape!) 

} 


func changePath() { 
    self.endAngle -= 0.1 
    self.circle.path = nil 

    let circlePath : UIBezierPath = UIBezierPath.init(arcCenter: CGPoint(x:0,y:0), radius: 35, startAngle: startAngle, endAngle: self.endAngle , clockwise: true) 
    self.circle.path = circlePath.cgPath 
} 
+1

您所指的'circle屬性是'SKShapeNode'嗎?這是否與您在init中創建的'shape' SKShpaeNode相同? – nathan

+1

aaaargh !!我真是個白癡。這正是問題所在。我創建了一個temp SKShapeNode,並且我忘記了更改該臨時節點上的路徑。 –

回答

2

它看起來像SKShapeNode你是指在你的changePath功能是不是在上面的初始化相同的。在正確的節點上更新路徑應該可以做到!