我正在努力在我的tic tac toe游戏中实现得分。我是Xcode的新手,所以不了解一切。以下是我的“如果用户获胜代码”,任何帮助表示赞赏!!
if([self checkforwin]){
NSString*winner = nil;
if (playertoken==1)winner=@"Player 2 Wins";
else if (playertoken==2)winner= @"Player 1 Wins";
score ++;
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Result"
message: winner
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[self resetboard];
[_audioPlayer play];
[alert show];
}
答案 0 :(得分:0)
我没有进入objective-c但是你必须为每个玩家等得分,得分2和得分1.
所以:
if (playertoken==1){
winner=@"Player 2 Wins";
score1 ++;
}
else if (playertoken==2){
winner= @"Player 1 Wins";
score2 ++;
}