2010-11-01 79 views
6

我真的不能找到浏览后,我的答案(而不是在cocos2d的很多话题与游戏中心)科科斯2d和游戏中心(排行榜问题)

我现在有我的沙盘游戏中心的成立,我能进行身份验证,但是当我创建排行榜时,它会在我假设的肖像中横向展开。试图旋转视图,但没有。我的游戏只在横向模式下运行。我正在运行beta 3 0.99.5。这里是我的代码供参考。

tempVC = [[RootViewController alloc] init]; 

GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease]; 

if (leaderboardController != nil) 
{ 
    leaderboardController.leaderboardDelegate = self; 
    [[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view]; 
    [tempVC presentModalViewController:leaderboardController animated:YES]; 
} 

真的很感激任何帮助。从cocos2d板获得没有回应。

编辑:

通过更改自动旋转CCDirector修复。此外,在显示游戏中心后,我遇到了失去多点触控功能的问题。该电路板的解雇应使用此:

[tempVC dismissModalViewControllerAnimated:YES]; 
[tempVC.view.superview removeFromSuperview]; 
+1

谢谢......我无法让我的排行榜或成绩解雇,并且您的编辑解决了我的问题! – jsherk 2012-07-09 20:36:17

回答

2

通过将自动旋转更改为CCDirector进行修正。此外,在显示游戏中心后,我遇到了失去多点触控功能的问题。该电路板的解雇应使用此:

[tempVC dismissModalViewControllerAnimated:YES]; 
[tempVC.view.superview removeFromSuperview]; 
+0

提供我的评论作为答案...见下文。 – RoLYroLLs 2012-04-19 23:23:13

+0

“通过改变自动旋转到CCDirector来固定”这是什么意思? – Jonny 2013-06-10 06:17:40

-1

甲GKLeaderboardViewController用于显示默认的排行榜,这是一个只肖像视图。要显示横向排行榜,您必须实现自己的自定义排行榜视图。

编辑:由于最初编写这个,GKLeaderboardViewController已被改进,以在任何方向工作得很好。

+0

那么像愤怒的小鸟这样的游戏是完全自定义的?我不知道我是否理解。 – Arbel 2010-11-01 13:02:12

+0

愤怒的小鸟将水晶SDK用于其排行榜。 http://www.crystalsdk.com/ – 2010-11-01 13:19:52

+0

谢谢你的回答 – Arbel 2010-11-01 13:55:49

0

当我的Cocos2D游戏处于横向模式时,在iPad上以纵向方式启动时出现同样的问题。通过从rootViewController而不是UIViewController派生我的GameKit控制器来解决这个问题。

@interface GCController:RootViewController的{

+0

不能为我工作。同样的问题。看起来实际的游戏中心视图横向翻转。所以我用横向排列的游戏排行榜显示覆盖不到屏幕的一半,并延伸到屏幕之外。 (不知道这是否有意义?)我完全失去了。 – Arbel 2010-11-07 05:26:29

2

=我有这个问题,并撕扯我的头发好几天,但我最终得到了它在横向模式很好地工作,不管是什么方式,用户拿着手机。这有点奇怪,如果有人知道更好,请让我知道!

1 - 我要在肖像,在我的情况下,IB

2完成(它调用排行榜控制器)的观点 - 只有当你支持纵向(即使它看起来工作像景观) -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

3 - 然后你需要调整&旋转排行榜 -

[self presentModalViewController: leaderboardController animated: YES]; 

leaderboardController.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0.0f)); 
leaderboardController.view.bounds = CGRectMake(0, 0, 480, 320); 
leaderboardController.view.center = CGPointMake(240, 160); 

4 - 变戏法似的!它工作正常。希望它也适用于你。

1

如果它可能会帮助,我发现,简单地从上海华去除GKLeaderboard是不是真的不够,所以你用

[tempVC.view后。superview removeFromSuperview];

,你也应该使用

[tempVC发布];

如果没有这个,GKLeaderboardViewController会做一些奇怪的事情,比如在第二次调用之后它不会自动在视图中自动旋转。

我希望它帮

1

上的cocos2d 1.0.1利用这一点,最新的稳定版本为2012年4月19日,这实际上不允许VC消失动画。也许运行这个:

[tempVC dismissModalViewControllerAnimated:YES]; 
[[[tempVC view] superview] performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1.2]; 
[tempVC performSelector:@selector(release) withObject:nil afterDelay:1.3];

+0

好的答案,但是从最近的iOS更新(iOS 4?)开始,你现在可以在这个方法中使用块来减少一点麻烦:'[vc dismissViewControllerAnimated:(BOOL)completion:^(void)completion];'Ex :[tempVC dismissViewControllerAnimated:YES completion:^ {tempVC.view removeFromSuperview]; [tempVC发布]; }];' – jmosesman 2012-07-03 05:15:02

1

正确的是是实现和包括该类别:

.H

#import <GameKit/GameKit.h> 

@interface GKLeaderboardViewController (additions) 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; 
-(NSUInteger)supportedInterfaceOrientations; 
@end 

.M

#import "GKLeaderboardViewController+additions.h" 

@implementation GKLeaderboardViewController (additions) 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); 
} 
-(NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskLandscape; 
} 
@end 
+1

您可能希望在'GKGameCenterViewController','GKAchievementViewController'和匹配生成控制器上创建相同的类别。 – Jonny 2013-06-10 06:36:43