2016-07-08 5 views
1

빠른 1에서 내 게임을 이전 중이므로이 기능을 수정하는 방법을 알 수 없습니다. 나는 터치가 일어나지 않는지 감지하려고 노력하고 있는데, 볼을 계속 움직여야합니다. 이 코드는 오류가 계속 발생합니다 touchesBegan의 잘못된 재 선언입니다. 이 문제를 해결하는 방법을 모르겠다. 나는 잠시 머물러있어 터치하지 않고도 공을 멈추게 할 수 없다. 당신이 볼은 사용자가 화면에서 손가락을 분리 할 때 중지해야하는 경우 감사스프라이트 키트 게임으로 오버라이드 기능을 사용합니다.

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 
    } 

답변

1

, 도와주세요, 아마 당신은 use하려는 :

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { 
} 

또는 this 당신이 때 접촉을 알 필요가 있다면 중단됨 :

override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { 
} 
+1

끝이났다. 완전 완료되었습니다. 감사합니다. 선생님. –