1

このチュートリアルを使用して GameCenter にアクセスしました。 http://www.raywenderlich.com/3276/how-to-make-a-simple-multiplayer-game-with-game-center-tutorial-part-12 ゲームセンターで遊ぶことはできますが、このコードを使用したい:

 SFAppDelegate * delegate = (SFAppDelegate *) [UIApplication sharedApplication].delegate;                
    [[GCHelper sharedInstance] findMatchWithMinPlayers:2 maxPlayers:2 viewController:self delegate:self];

このコードは機能するはずですが、 i を呼び出すと、上に青いツールバーのある黒い画面しか表示されません。ここでの「自己」は UIViewController であり、このコントローラーは GCHelper デリゲート メソッドを実装します。

メソッド find ... は次のようになります。

- (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController delegate:(id<GCHelperDelegate>)theDelegate {

    if (!gameCenterAvailable) return;

    matchStarted = NO;
    self.match = nil;
    self.presentingViewController = viewController; // ?
    delegate = theDelegate;               
    [presentingViewController dismissModalViewControllerAnimated:NO];


    if (pendingInvite != nil) 
    {   
        [presentingViewController dismissModalViewControllerAnimated:NO];
        GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:pendingInvite] autorelease];
        mmvc.matchmakerDelegate = self;
        [presentingViewController presentModalViewController:mmvc animated:YES];

        self.pendingInvite = nil;
        self.pendingPlayersToInvite = nil;
    }
    else 
    {   
        [presentingViewController dismissModalViewControllerAnimated:NO];
        GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; 
        request.minPlayers = minPlayers;     
        request.maxPlayers = maxPlayers;
        request.playersToInvite = pendingPlayersToInvite;

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

        [presentingViewController presentModalViewController:mmvc animated:YES];

        self.pendingInvite = nil;
        self.pendingPlayersToInvite = nil;
    }
}

私は何が間違っているのかわからない....修正のための提案をありがとう。:)

4

0 に答える 0