gpt4 book ai didi

ios - 使用 Sprite 套件和 swift 绘制线条

转载 作者:可可西里 更新时间:2023-11-01 01:43:56 27 4
gpt4 key购买 nike

我正在使用带有 Swift 的 Sprite 工具包来测试用手指绘制的线条。

代码:

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
}

override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) {

}

但是得到的线条是空的,只有边框有颜色(图片)。

enter image description here

有什么想法吗?

最佳答案

SKShapeNode 有一个名为 fillColor 的属性,默认设置为 clearColor。在您的代码中,您只将 strokeColor(轮廓)设置为红色,但您也应该将 fillColor 设置为红色。

您可以使用 lineNode.fillColor = UIColor.redColor()

祝你好运!

关于ios - 使用 Sprite 套件和 swift 绘制线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25329921/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com