我正在为我的游戏开发多人游戏,我遇到了以下问题 我正在使用Cocos 2d 2.1,iOS 6和以下代码来显示红娘(横向)
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[GCHelper sharedInstance] findMatchWithMinPlayers:2 maxPlayers:4 viewController:[app navController] delegate:self];
这就是
的显示方式以下代码用于该功能
- (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];
}
答案 0 :(得分:0)
是HelloWorldLayer中的这段代码吗?如果那是导演所说的第一层?我有同样的问题,但如果我严格遵循为我创建的cocos2d模板,它就会修复。这意味着我使用IntroLayer作为初始层,然后从那里转换到我拥有游戏中心代码的HelloWorldLayer。我认为它与导演加载太晚有关,但我不确定
答案 1 :(得分:0)
当您尝试推送UIViewController
时会发生这种情况,但您的应用中只有UIView,而且没有UIViewController 。我猜,你没有rootViewController
。
如果您使用的是EAGLView
模板,则必须为UIView声明一个UIViewController 。这可以很简单,
- (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将消失,窗口将正确形成。