0
votes

I've created an circle with an UIBezierPath which I add to a SKShapeNode. The circle displays fine. But when I want to update the path nothing happens. I keep seeing the same initial path I created. Do I have to call some kind of update function for the path to update properly? Color changes and stroke changes work fine but the path remains unchanged.

 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
Is the circle property the SKShapeNode you are referring to? And is this the same as the shape SKShpaeNode you create in the init?nathangitter
aaaargh!! I'm such an idiot. that's exactly what the problem was. I created a temp SKShapeNode and I forgot to change the path on that temp node.Ramin Afshar

1 Answers

2
votes

It looks like the SKShapeNode you are referring to in your changePath function isn't the same an in the initializer above. Updating the path on the correct node should do the trick!