想制作像Paper.io这样的应用。我能够使应用程序沿其路径绘制线条。但是无法创造封闭的道路。
func action()
{
var action = SKAction()
switch direction {
case 1:
action = SKAction.moveBy(x:164,y:0,duration:0.6)
case -1:
action = SKAction.moveBy(x:-164,y:0,duration:0.6)
case 2:
action = SKAction.moveBy(x:0,y:164,duration:0.6)
case -2:
action = SKAction.moveBy(x:0,y:-164,duration:0.6)
default:
return
}
print("touch start ",posx,posy)
var repeatAction = SKAction.repeatForever(action)
ball.run(repeatAction, withKey: "Moving")
}
答案 0 :(得分:0)
我相信你需要在动作旁边创建一个CGPath
对象。然后,您可以使用此路径创建具有SKShapeNode
属性的fillColor
。
let path = CGMutablePath()
// Construct the path e.g. using path.addLine(point:transform:)
let shape = SKShapeNode(path: path)
shape.fillColor = .blue