用我的手指在SpriteKit和swift 3中绘图

时间:2017-02-17 19:11:09

标签: ios swift sprite-kit

我发现这个代码在线完成了这项工作,但发布的代码并不完整,所以如果有人可以帮我解决以下问题

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
    touch = touches.anyObject() as UITouch!
    firstPoint = touch.locationInNode(self)
}

override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
    var touch = touches.anyObject() as UITouch!
    var positionInScene = touch.locationInNode(self)

    lineNode.removeFromParent()
    CGPathMoveToPoint(pathToDraw, nil, firstPoint.x, firstPoint.y)
    CGPathAddLineToPoint(pathToDraw, nil, positionInScene.x, positionInScene.y)
    lineNode.path = pathToDraw
    lineNode.lineWidth = 10.0
    lineNode.strokeColor = UIColor.redColor()

    self.addChild(lineNode)
    firstPoint = positionInScene
}

什么是lineNode和pathToDraw,如果你能告诉我如何编写他们的代码,或者将我重定向到可以提供帮助的东西。

0 个答案:

没有答案