Ios 游戏中心配对后,我的应用程序将切换到默认游戏视图,而不是当前加入的游戏
我能够按下“查找游戏”按钮,游戏中心配对成功。我已将segue设置为Modal。找到匹配项后,我希望它在另一个视图控制器(GamePlaySecene)中转换到该匹配项。现在它正在这样做,但有点错误。它不会将用户带到他们刚刚加入的当前游戏,而是显示没有交互的游戏布局,而不是刚刚加入的实际游戏Ios 游戏中心配对后,我的应用程序将切换到默认游戏视图,而不是当前加入的游戏,ios,segue,game-center,Ios,Segue,Game Center,我能够按下“查找游戏”按钮,游戏中心配对成功。我已将segue设置为Modal。找到匹配项后,我希望它在另一个视图控制器(GamePlaySecene)中转换到该匹配项。现在它正在这样做,但有点错误。它不会将用户带到他们刚刚加入的当前游戏,而是显示没有交互的游戏布局,而不是刚刚加入的实际游戏 // viewcontroller.m (Main Menu) - (IBAction)findGame:(UIButton *)sender { [[GameKitHelper sharedInsta
// 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;
您的GameViewController可能只是在演示时创建了一个新场景。把密码贴出来。如果(skView.scene==nil{/*create&present scene here*/}搜索了我的项目,没有结果,则应该使用
保护它。