2016-03-26 4 views
0

アプリを作成しようとしていますが、画面に初めてタッチするとNSTimerが起動しますが、NuTimerを使用してタッチが開始された関数でシグナルsigbartエラーが発生します。他の誰かが同じ結果を得るために使うことのできる方法があれば、私はそれを感謝します。touches内でNSTimerを使用したときにsigbartエラーが発生しました

これは、あなたが選択のための機能timerUpdateを追加する必要が私の基本的な現在のコード

var condition = 0 

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

    if(condition == 1) { 
    timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("timerUpdate"), userInfo: nil, repeats: true) 
    } 

    cat.physicsBody?.velocity = CGVectorMake(0, 0) 
    cat.physicsBody?.applyImpulse(CGVectorMake(0, 1)) 


} 

答えて

1

です。

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    if(condition == 1) { 
     timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("timerUpdate"), userInfo: nil, repeats: true) 
    } 

    cat.physicsBody?.velocity = CGVectorMake(0, 0) 
    cat.physicsBody?.applyImpulse(CGVectorMake(0, 1)) 
} 

func timerUpdate(){ 
    print("timerUpdate") 
} 
+1

大変ありがとうございました。とにかく大変ありがとう。 –

関連する問題