Create a line with two CGPoints SpriteKit Swift

后端 未结 4 1104
名媛妹妹
名媛妹妹 2021-02-08 01:47

I am trying to make a simple app where you touch a point, and a sprite follows a line through that point to the edge of the screen, no matter where you touch. I want to draw lin

4条回答
  •  忘了有多久
    2021-02-08 02:02

    For Swift 3, the CGPathMoveToPoint method doesn't like a nil for the second argument anymore, so I needed a new solution. Here's what I came up with:

    let line_path:CGMutablePath = CGMutablePath()
    line_path.move(to: CGPoint(x:x1, y:y1))
    line_path.addLine(to: CGPoint(x:x2, y:y2))
    

提交回复
热议问题