在App使用过程中,cocos2d v3重新定位屏幕

所以在cocos2d(我相信我是在V2.1)我做了这个locking和设置方向:

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; const UIInterfaceOrientation ORIENTATION = delegate.navController.interfaceOrientation; delegate.navController. delegate.navController.screenOrientation = ORIENTATION == UIInterfaceOrientationMaskPortrait; UIViewController *mVC = [[UIViewController alloc] init]; [delegate.navController presentModalViewController:mVC animated:NO]; [delegate.navController dismissModalViewControllerAnimated:NO]; 

随着一些function添加到AppDelegate。 我似乎无法在iOS7和cocos2d v3中获得相同的结果。

我已经挖了一下,适当的function似乎已经到位,但似乎无法设置一个全局variables来设置方向,并在特定时间只返回一个我想要的。 有人能指出我的正确道路吗? 我想我错过了一些非常小的东西,因为正确的代码似乎已经在那里了。

这是我的AppDelegate的代码

 @implementation AppDelegate -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self setupCocos2dWithOptions:@{ CCSetupShowDebugStats: @(NO), }]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; return YES; } -(CCScene *)startScene { return [HomeScreen scene]; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrientation); } 

我的代码从来没有碰到interfaceOrientation函数。

思考?!?

几天后,我想出了一个解决scheme:

在AppDelegate我需要这个function:

 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (!self.lockedToOrientation) { if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ){ return UIInterfaceOrientationMaskPortrait; } return UIInterfaceOrientationMaskPortrait; } else { return self.lockedToOrientation; } } 

哪里

 @property UIInterfaceOrientationMask lockedToOrientation; 

希望这可以帮助别人!

干杯。