1
我正在从swift 1移植我的游戏,我无法弄清楚如何解决这个功能。我试图检测是否没有接触,这应该保持球静止。这是我的代码,并不断得到错误无效的touchesBegan重新声明。我不知道如何解决这个问题,我被困了一段时间,无法让球停止移动时,没有触及现在。请帮帮忙,谢谢用sprite套件游戏覆盖功能
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
// do nothing if ad is showing
if Ad.share().showing {
return
}
let touch = touches.first! as UITouch
let touchedLocation = touch.locationInNode(self)
// change the speedXFirst of the ball if it starts
if start {
// start move
let moveRight = touchedLocation.x > CGRectGetMidX(self.frame)
let speedX = moveRight ? ballSpeedX : -ballSpeedX
ball.speedXFirst = speedX
}
// start game if it stops
else {
startGame()
}
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { //error RIGHT HERE
if start {
// stop move
ball.speedXFirst = 0
}
感动完了,谢谢先生 –