不幸的是,我不太了解UIViewControllers,也不清楚它们是如何与cocos2d场景相结合的。但是,我能够在iPhone上成功加载我的cocos2d(仅限风景)游戏之上的标准游戏中心排行榜视图。但是,我的游戏是一个通用的应用程序,当我在iPad上尝试时,游戏中心视图以纵向方向加载,大约是它应该的大小的一半(仅填满屏幕的四分之一),并且不居中。当我旋转设备时,游戏中心视图将自己定位为横向,但实际上非常伸展,看起来它不是在横向视图中为iPad设计的。
有人有任何建议吗?
- (void) showLeaderboard
{
if(![MyAppDelegate isGameCenterAPIAvailable])
return;
if ([GKLocalPlayer localPlayer].isAuthenticated == YES)
{
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
tempVC = [[RootViewController alloc] init];
GKLeaderboardViewController *leaderboard = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboard != NULL)
{
leaderboard.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
// Pause game
[[CCDirector sharedDirector] pause];
[tempVC presentModalViewController:leaderboard animated: NO];
leaderboard.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0.0f));
[leaderboard.view setCenter:CGPointMake(screenSize.height/2, screenSize.width/2)];
leaderboard.modalPresentationStyle = UIModalPresentationCurrentContext;
}
}
}
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[tempVC dismissModalViewControllerAnimated: YES];
[tempVC.view.superview removeFromSuperview];
[tempVC release];
tempVC = nil;
// Resume game
[[CCDirector sharedDirector] resume];
}
答案 0 :(得分:0)
请查看Implementing iAds in Cocos2d Application。
[self.view addSubview:self.bannerView];
在本教程中,addSubview UIView对象为RootViewController.view,即cocos2d应用程序模板,而不是EAGLView。