IOS 6.1游戏中心汽车配对陷入困境

时间:2013-02-08 13:29:30

标签: ios ios6 game-center

在我的游戏中,我正在使用自动匹配制作。它适用于IOS 5.0,但使用IOS 6.1我无法连接。匹配制作处理停留在“正在连接......”

以下是代码:

- (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers
                 viewController:(UIViewController *)viewController
                       delegate:(id<GCHelperDelegate>)theDelegate {
    GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
    request.minPlayers = minPlayers;
    request.maxPlayers = maxPlayers;

    GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
    mmvc.matchmakerDelegate = self;

    self.presentingViewController = viewController;
    [presentingViewController presentModalViewController:mmvc animated:YES];

}


#pragma mark GKMatchmakerViewControllerDelegate
// The user has cancelled matchmaking
- (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController *)viewController {
    [presentingViewController dismissModalViewControllerAnimated:YES];
}

// Matchmaking has failed with an error
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error {
    [presentingViewController dismissModalViewControllerAnimated:YES];
    NSLog(@"Error finding match: %@", error.localizedDescription);
}

// A peer-to-peer match has been found, the game should start
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)theMatch {
    [presentingViewController dismissModalViewControllerAnimated:YES];
    //self.match = theMatch;
    //match.delegate = self;
    //if (!matchStarted && match.expectedPlayerCount == 0) {
        NSLog(@"Ready to start match!");
    //}
}

--------请注意,这在IOS 5中完全有效----------

0 个答案:

没有答案