2016-07-08 9 views
0

私は単純なゲームを持っており、移行しようとしています。私はスイフト2の使用を開始する前にすべてが働いた。私は仕事をするためにtouchesBeganを得ることができない。私は、オーバーライドと他のものの束を削除しようとしました。ボールはタッチが止まると止まると考えられます。エラーが発生した場所をコメントしました。ありがとうございます。SpriteKit Swift2- UITouch上書きエラー:touchesBegan

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


    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: Invalide redeclaration of touchesBegan(::with event).. 
    if start { 

     // stop move 
     ball.speedXFirst = 0 
    } 
} 
+0

!!!:ちょうど これを削除 –

答えて

0

同じ機能を2つ持っているため、コードは機能しません。あなたは、同じクラスに二度同じ機能を持つようにすることはできません

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

//ERROR: Invalide redeclaration of touchesBegan(::with event).. 

    if start { 

      // stop move 
      ball.speedXFirst = 0 
    } 
}