首页 文章

错误的游戏中心Matchmaker外观

提问于
浏览
2

我正在为我的游戏开发多人游戏,我遇到了以下问题我正在使用Cocos 2d 2.1,iOS 6和以下代码来显示红娘(横向)

AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
    [[GCHelper sharedInstance] findMatchWithMinPlayers:2 maxPlayers:4 viewController:[app navController] delegate:self];

这就是它如何出现
enter image description here

以下代码用于该功能

- (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];

GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;

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

[presentingViewController presentViewController:mmvc animated:YES completion:nil];

}

2 回答

  • 0

    这是HelloWorldLayer中的代码吗?如果那是导演所说的第一层?我有同样的问题,但如果我严格遵循为我创建的cocos2d模板,它会修复 . 这意味着我使用IntroLayer作为初始层,并从那里转换到我拥有游戏中心代码的HelloWorldLayer . 我认为它与导演加载太晚有关,但我不确定

  • 0

    当您尝试按 UIViewControlleryou only have a UIView in your app, and no UIViewController 时会发生这种情况 . 让我猜,你没有 rootViewController .

    如果您使用 EAGLView 模板, you must declare a UIViewController for the UIView . 这可以很简单,

    - (void) applicationDidFinishLaunching:(UIApplication *)application
    {
      window.rootViewController = [[UIViewController alloc] init]; 
      window.rootViewController.view = glView; // MUST SET THIS UP,
      // NOW THE EAGLView HAS A UIViewController.
    
      [glView startAnimation];
    }
    

    然后,无论何时你想推送其中一个GameKit UIViewControllers ,使用你的Window对象的 presentViewController 方法 rootViewController

    例如:

    [self.window.rootViewController presentViewController:vc animated:TRUE completion:^(void){puts("DONE");} ] ;
    

    bugginess将消失,窗口将正确形成 .

相关问题