GameCenter 方向问题
我在实施 Game Center 时遇到了很多问题。
我的游戏是基于 Cocos2d 但我的菜单是用 XIB 来做的。所以我的主窗口是这样的:
- UIWindow
- UINavigationController
- 导航栏
- UIViewController [菜单]
- UINavigationItem
当我单击“Play”时,我创建一个名为 Menu2Game.hmxib 的新视图控制器 我将 OpenGL 添加到此视图,然后 Menu2Game 将其添加到我的菜单视图
menu2Game = [[Menu2Game alloc] initWithNibName:@"Menu2Game" bundle:nil];
[menu2Game setView:glView];
[self.view addSubview: menu2Game.view];
我不知道为什么我无法直接添加它......但是当我点击排行榜时我会做同样的事情。直接在菜单上呈现视图不起作用。
UIViewController *tempView = [[UIViewController alloc] init];
[self.view addSubview:tempView.view];
[[GameCenter sharedGameCenter] showLeaderboard:tempView];
当我调用我的 Leaderbords 时,就是这个代码。
if ([self isGameCenterAvailable]) {
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil) {
screen = screen2;
leaderboardController.leaderboardDelegate = self;
[screen presentModalViewController: leaderboardController animated: YES];
[leaderboardController setCategory:@"015.1"];leaderboardController.view.frame.origin.y);
leaderboardController.view.bounds = CGRectMake(0, 0, 480, 320);
leaderboardController.view.center = CGPointMake(240, 160);
}
}
则不尊重应用程序的方向
这里的问题是,如果它是横向的, 。开始于 80, 320,结束于 480, 320 它出现了,您可以使用它,但没有出现在 ----> 中。 它会向这个方向移动 45 度
如果您以纵向 [任意] 方式握住手机, 。它看起来只是排行榜的一小部分,面对真正的方向,但协调与你所持有的不同。在我的列表中,它没有排列的肖像。
我该如何解决这个问题?我只有 1 周的时间来完成这款游戏,这是我唯一怀念的事情。
谢谢大家
I got a lot of problems implementing Game Center.
My game its based on Cocos2d But my Menu I do it with XIB. So the main window i make it like this:
- UIWindow
- UINavigationController
- Navigation Bar
- UIViewController [Menu]
- UINavigationItem
When i click on Play I create a new View Controller called Menu2Game.h.m.xib And i add the OpenGL to this view, and then Menu2Game add it to my menu View
menu2Game = [[Menu2Game alloc] initWithNibName:@"Menu2Game" bundle:nil];
[menu2Game setView:glView];
[self.view addSubview: menu2Game.view];
I don't know why I can't add it directly... But when I click on leaderboards I do the same thing. Presenting the view directly on Menu doesn't work.
UIViewController *tempView = [[UIViewController alloc] init];
[self.view addSubview:tempView.view];
[[GameCenter sharedGameCenter] showLeaderboard:tempView];
And when I call my leaderbords its this code.
if ([self isGameCenterAvailable]) {
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil) {
screen = screen2;
leaderboardController.leaderboardDelegate = self;
[screen presentModalViewController: leaderboardController animated: YES];
[leaderboardController setCategory:@"015.1"];leaderboardController.view.frame.origin.y);
leaderboardController.view.bounds = CGRectMake(0, 0, 480, 320);
leaderboardController.view.center = CGPointMake(240, 160);
}
}
The problem here its that doesn't respects the application Orientation
If its in Landscape. It start in 80, 320, And finish in 480, 320
It appears and you can use it but appears not in ----> this direction it moves like with 45 degrees
And if you hold the phone in Portrait [Any]. It appears only a small fragment of the leader boards, Facing the real orientation, but the coordinated are different it takes the ones you are holding. And in my plist its not permuted portrait.
How could i fix this? I got 1 week to finish this game and this is the only thing I miss.
Thanks to everybody
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么,但只是创建应该旋转并返回 true..,并消除所有修改游戏中心的代码
:
I don't know why but just create should rotate and return true.., and eliminate all the code that modify the game center
this one: