私はゲーム センターを使用してターン ベースの iOS ゲームに取り組んでおり、現在、テスト アカウントでゲーム センターの 6 つのゲームに参加していますが、スワイプして 1 つを終了しようとするたびに (実際にはゲームが終了するはずです。 test アカウントはその中の唯一のものです) テーブルからゲームを一瞬削除し、すぐに置き換えて終了しません。
これが私の playerQuitForMatch 関数です:
// Handle players leaving the match in and out of turn.
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController
playerQuitForMatch:(GKTurnBasedMatch *)match
{
// If the player was the current participant, remove them from the next participants array.
if ([match.currentParticipant.playerID isEqualToString:GKLocalPlayer.localPlayer.playerID])
{
NSMutableArray* nextParticipants = [NSMutableArray arrayWithArray:[match participants]];
[nextParticipants removeObjectIdenticalTo:[match currentParticipant]];
// If they were the last player, end the match because it is empty.
if ([nextParticipants count] == 0)
{
[match endMatchInTurnWithMatchData:match.matchData completionHandler:nil];
}
// Otherwise, remove them from the match and pass priority.
else
{
[match participantQuitInTurnWithOutcome:GKTurnBasedMatchOutcomeQuit
nextParticipants:nextParticipants
turnTimeout:0.0f
matchData:match.matchData
completionHandler:nil];
}
}
// If they weren't the current participant, just remove them from the match.
else
{
NSMutableArray* nextParticipants = [NSMutableArray arrayWithArray:[match participants]];
[nextParticipants removeObjectIdenticalTo:[match currentParticipant]];
// The player can't be the last person in the game if they aren't the active player.
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:nil];
}
NSLog(@"playerquitforMatch, %@, %@", match, match.currentParticipant);
}
コンソール出力は次のとおりです。
2013-05-04 13:16:13.180 XYZ Mobile[7799:c07] Authenticating local user...
2013-05-04 13:16:13.587 XYZ Mobile[7799:c07] Authentication changed: player authenticated.
May 4 13:16:13 folsom-wireless-153.dynamic2.rpi.edu XYZ Mobile[7799] <Info>: 13:16:13.597120 com.apple.AVConference: GKSConnSettings: set server: {
"gk-cdx" = "17.173.254.218:4398";
"gk-commnat-cohort" = "17.173.254.220:16386";
"gk-commnat-main0" = "17.173.254.219:16384";
"gk-commnat-main1" = "17.173.254.219:16385";
}
2013-05-04 13:16:21.380 XYZ Mobile[7799:c07] 101
2013-05-04 13:16:58.150 XYZ Mobile[7799:c07] New Game Button Pressed
2013-05-04 13:17:00.146 XYZ Mobile[7799:c07] playerquitforMatch, <GKTurnBasedMatch 0x949ece0 id:0a8b8246-1872-410e-b9ae-819a9a00d4ff status:Open message:(null) taken:(null) created:2013-04-24 23:32:35 +0000
current:<GKTurnBasedParticipant 0x949ad50 - id:(null) status:Matching outcome:None lastTurn:(null)>
participants:
<GKTurnBasedParticipant 0x949ad40 - id:G:1759434517 (local player) status:Done outcome:Quit lastTurn:(null)>
<GKTurnBasedParticipant 0x949ad50 - id:(null) status:Matching outcome:None lastTurn:(null)>
<GKTurnBasedParticipant 0x949f2b0 - id:(null) status:Matching outcome:None lastTurn:(null)>
<GKTurnBasedParticipant 0x949f2c0 - id:(null) status:Matching outcome:None lastTurn:(null)>
<GKTurnBasedParticipant 0x949f650 - id:(null) status:Matching outcome:None lastTurn:(null)>
<GKTurnBasedParticipant 0x949f660 - id:(null) status:Matching outcome:None lastTurn:(null)>
<GKTurnBasedParticipant 0x949bc20 - id:(null) status:Matching outcome:None lastTurn:(null)>
<GKTurnBasedParticipant 0x949bc30 - id:(null) status:Matching outcome:None lastTurn:(null)>
>, <GKTurnBasedParticipant 0x949ad50 - id:(null) status:Matching outcome:None lastTurn:(null)>
2013-05-04 13:17:08.523 XYZ Mobile[7799:c07] has cancelled