在Game Center配对后,我的应用程序切换到默认游戏视图,而不是当前加入的游戏

时间:2015-02-14 16:47:00

标签: ios segue game-center

我可以按查找游戏按钮,游戏中心配对成功。我把segue设置为Modal。找到匹配后,我希望它在另一个视图控制器(GamePlayScene)中转换到该匹配。现在它目前正在做这个,但稍有不妥。它不是将用户带到他们刚刚加入的当前游戏,而是仅显示没有交互的游戏布局,而不是刚刚加入的实际游戏。

// viewcontroller.m (Main Menu)

- (IBAction)findGame:(UIButton *)sender {

[[GameKitHelper sharedInstance]
 findMatchWithMinPlayers:2 maxPlayers:2 viewController:self]; // Start matchmaking when pressing the find game button
}
  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"GamePlayScene"])
    {
        GameViewController *c = (GameViewController*)segue.destinationViewController;
        c.match = [GameKitHelper sharedInstance].currentMatch;
    }
}

// GameKitHelper.m

- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
{
    [presentingViewController dismissViewControllerAnimated:YES completion:nil];
    [presentingViewController performSegueWithIdentifier:@"GamePlayScene" sender:match];

    self.currentMatch = match;

0 个答案:

没有答案