Swift SKShapeNode shapeWithSplinePoints

后端 未结 1 1306
一向
一向 2021-01-16 21:02

I am trying create a CGPath for a node to follow but when I have tried using SKShapeNode as defined in the actions and constants slide from 608_hd_best_practices_for_buildin

1条回答
  •  粉色の甜心
    2021-01-16 21:27

    init(splinePoints:count:) takes an UnsafeMutablePointer (i.e., a C array of CGPoints) and an unsigned integer as its arguments. It also returns an SKShapeNode object not a CGPathRef. Try the following...

    let p = SKShapeNode(splinePoints: &path, count: UInt(count))
    

    EDIT: Make the following changes as well

    let speed:CGFloat = 1.0
    
    let action = SKAction.followPath(p.path, speed: speed)
    sprite.runAction(action)
    

    0 讨论(0)
提交回复
热议问题