Cocos2d 版本:v0.99.04
我正在将 Game Center 添加到我当前的应用程序中,并且我找到了一些代码来打开 GKMatchmakerViewController。它似乎运作良好,除非它被解雇时它将模拟器中的方向更改为纵向。游戏只在横向运行。我将设备转回横向,所有 cocos2d 场景仍然可以正常工作,但是如果我打开警报或对等选择器,它们会以纵向模式打开。我可以打开和关闭场景,但它们现在都会显示这种行为。使用实际设备也会发生这种情况。
// *.h
UIViewController *tempVC;
// *.m
// Open
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 2;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
tempVC=[[UIViewController alloc] init];
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController: mmvc animated: YES];
// Close
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view removeFromSuperview];
[tempVC release];
一旦我点击了dismissModalViewControllerAnimated,那就是模拟器旋转的时候。
提前感谢您的帮助。