【发布时间】:2018-07-30 09:06:50
【问题描述】:
我在屏幕上有一个圆圈,当我按下屏幕右侧时,它会向右移动,当我按下屏幕左侧时,它会向左移动。现在我需要做到这一点,当我开始触摸时,我的圆圈向右移动,但如果我松开触摸,圆圈将停止,直到我再次按下屏幕。
这是在我的 touchesBegan 函数中。
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if location.x < self.size.width / 2 {
let moveLeft = SKAction.moveToX(self.frame.width / 3, duration: 1.0)
Ball.runAction(moveLeft)
}
else {
let moveRight = SKAction.moveToX(self.frame.width / 1.445, duration: 1.0)
Ball.runAction(moveRight)
}
}
这是我目前所拥有的。
【问题讨论】:
标签: swift xcode sprite game-physics