我有什么似乎是一个相当普遍的问题,但我的搜索和解决方案的实现还没有制定。
我已经建立了一个cocos2d的游戏,是仅是景观,但需要访问GameCenter的。 GameCenter的工作,并启用人像模式,但它也使游戏翻转到肖像模式了。
我已经尝试以下修正:
只有在我的OS 6的Game Center登录锁定在景观
仅在景观应用的GameCenter认证抛出UIApplicationInvalidInterfaceOrientation
在iOS 6中添加错误的GameCenter的景观仅cocos2d的应用程序后,
科科斯2D 2.0 shouldAutorotate不工作?
我认为,问题是,我已经建立了使用CCLayers代替UIViewControllers游戏
例如:MenuLayer.h
@interface MenuLayer : CCLayer <GKAchievementViewControllerDelegate, GKLeaderboardViewControllerDelegate, UINavigationControllerDelegate>{
..my header info..
}
MenuLayer.m
...
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL)shouldAutorotate {
return [[UIDevice currentDevice] orientation] != UIInterfaceOrientationPortrait;
}
-(void)authenticateLocalPlayer
{
GKLocalPlayer * localPlayer= [GKLocalPlayer localPlayer];
if(localPlayer.authenticated == NO)
{
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[[GKLocalPlayer localPlayer] setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error) {
if (viewcontroller != nil) {
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentModalViewController:viewcontroller animated:YES];
}else if ([GKLocalPlayer localPlayer].authenticated)
{
//do some stuff
}
})];
}
else
{
[localPlayer authenticateWithCompletionHandler:^(NSError *error){
if(localPlayer.isAuthenticated)
{
//Peform Additionl Tasks for the authenticated player.
}
}];
}
}
}
...
既然我已经建立了使用CCLayers代替UIViewControllers的比赛中,我有什么办法? 我在假设CCLayers不调用使用supportedInterfaceOrientations或shouldAutorotate正确吗?
还是我应该以某种方式改变这个代码来解决这个问题:
// Create a Navigation Controller with the Director
navController_ = [[UINavigationController alloc] initWithRootViewController:director_];
navController_.navigationBarHidden = YES;