2012-08-15 55 views
1

我一直在測試兩款設備上的基於回合的遊戲應用程序。 當設備1退出(通過刷卡並從GKTurnBasedMatchmakerViewController中刪除匹配項)時,它更新設備2以顯示匹配已完成(但它仍顯示在GKTurnBasedMatchmakerViewController中,匹配是其他玩家的轉向),但設備1沒有更新!結束GKTurnBasedMatch時的問題

它在Game Over部分的GKTurnBasedMatchmakerViewController中說過結束的匹配,但表示「沒有結果」,並且來自蘋果紀錄片 - 參與者的結果尚未設置(通常是因爲匹配仍在進行中)。

我想知道如何將其設置爲其他內容,以及通過退出方式調用(假定)的方法。

在此先感謝。

回答

5
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController playerQuitForMatch:(GKTurnBasedMatch *)match { 

    if ([match.currentParticipant.playerID isEqualToString:[GKLocalPlayer  localPlayer].playerID]) { 

     [match participantQuitInTurnWithOutcome:GKTurnBasedMatchOutcomeQuit nextParticipants:nextParticipant turnTimeout:GKTurnTimeoutNone matchData:data completionHandler:^(NSError *error) { 

      [match removeWithCompletionHandler:^(NSError *error) { 

       //Player quitted and match removed 

      }]; 

     }]; 

    } 
    else { 

     [match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:^(NSError *error) { 

      [match removeWithCompletionHandler:^(NSError *error) { 

       //Player quitted and match removed 

      }]; 

     }]; 

    } 

} 

對於設備2

-(void)handleTurnEventForMatch:(GKTurnBasedMatch *)match { 

    if (player2.matchOutcome==GKTurnBasedMatchOutcomeQuit){ 

     //Your opponent quitted do something 

    } 

} 
+0

當比賽結束,它不從沙箱移除遊戲。你可以說如何從沙箱中刪除退出遊戲 – 2013-06-06 04:49:47

+0

如果匹配結束或用戶已從該匹配中退出,那麼只需使用-removeWithCompletionHandler:^(NSError * error)方法。 – 2013-06-13 20:49:19

+0

確定''''''''''''''''你確定''''''''''''在swipe-to-remove實例中調用了'turnBasedMatchmakerViewController:playerQuitForMatch:'?我在測試中沒有看到這種情況。 – livingtech 2014-07-18 22:31:26