Ios 我需要快速移动节点到某个位置
我创建了这个代码来快速移动场景中的节点。我创建了一个生成一个名为ball的节点的函数,但它有两种不同的纹理。因此,我使用一个函数生成两个不同的节点。现在我必须单独移动每个节点。即使屏幕上有10个球。这可能吗?我发现了一个密码,但当我的手指移动太快时,它就会停止移动。我粘贴的代码根本不起作用 有人能帮我吗?谢谢Ios 我需要快速移动节点到某个位置,ios,swift,Ios,Swift,我创建了这个代码来快速移动场景中的节点。我创建了一个生成一个名为ball的节点的函数,但它有两种不同的纹理。因此,我使用一个函数生成两个不同的节点。现在我必须单独移动每个节点。即使屏幕上有10个球。这可能吗?我发现了一个密码,但当我的手指移动太快时,它就会停止移动。我粘贴的代码根本不起作用 有人能帮我吗?谢谢 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
location = touch.location(in: self)
if ball.name == "ballblauw" {
if location == ball.position {
let ballX = ball.position.x
let ballY = ball.position.y
ballLocation = CGPoint(x: ballX, y: ballY)
}
}
if ball.name == "ballrood" {
if location == ball.position {
let ballX = ball.position.x
let ballY = ball.position.y
ballLocation = CGPoint(x: ballX, y: ballY)
}
}
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
location = touch.location(in: self)
if ball.name == "ballblauw" {
ballLocation = location
}
if ball.name == "ballrood" {
ballLocation = location
}
}
}
override func touchsbegind(touch:Set,with event:UIEvent?{
接触{
位置=触摸。位置(in:self)
如果ball.name==“ballblauw”{
如果位置==球位置{
让ballX=ball.position.x
让ballY=ball.position.y
ballLocation=CGPoint(x:ballX,y:ballY)
}
}
如果ball.name==“ballrood”{
如果位置==球位置{
让ballX=ball.position.x
让ballY=ball.position.y
ballLocation=CGPoint(x:ballX,y:ballY)
}
}
}
}
覆盖功能触摸移动(touchs:Set,带有事件:UIEvent?){
接触{
位置=触摸。位置(in:self)
如果ball.name==“ballblauw”{
ballLocation=位置
}
如果ball.name==“ballrood”{
ballLocation=位置
}
}
}