0
我在屏幕右側有一個向右移動的屏幕,當我按下屏幕左側時,屏幕上會出現一個圓圈。現在我需要做到這一點,當我開始觸摸時,我的圓圈向右移動,但是如果我釋放觸摸,那麼圓圈將停止,直到我再次按下屏幕。只有在按下時纔會移動Sprite?
這是在我的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)
}
}
這是我到目前爲止。