私はObjective-Cで簡単なテニスゲームを作成しています。現在、プレーヤーまたはコンピューターが得点すると、「タップして開始」というメッセージが表示され、ボールがリリースされます(ラケットに親指を置き、もう1つの親指でタップして開始するのは少し厄介です)。
スコアごとにタップする必要がないように、ゲームにタイマーを追加するにはどうすればよいですか?
(このコードは、新しいゲームがあり、スコアがある場合のリセット方法です)
{
self.gameState = kGameStatePaused;
ball.center = self.view.center;
if(newGame)
{
if(computerScoreValue > playerScoreValue)
{
tapToBegin.textAlignment = UITextAlignmentCenter;
tapToBegin.text = @"Computer Wins!";
AudioServicesPlaySystemSound(booFileID);
}
else
{
tapToBegin.textAlignment = UITextAlignmentCenter;
tapToBegin.text = @"You Win!";
AudioServicesPlaySystemSound(clappingFileID);
}
computerScoreValue = 0;
playerScoreValue = 0;
}
else
{
tapToBegin.textAlignment = UITextAlignmentCenter;
tapToBegin.text = @"Tap to Begin";
}
playerScore.text = [NSString stringWithFormat:@"%d",playerScoreValue];
computerScore.text = [NSString stringWithFormat:@"%d",computerScoreValue];
}