Cocos2d 3.0设置纵向

Gur*_*uru 2 cocos2d-iphone

已经在AppDelegate.m中添加了以下代码,但仍然没有在纵向工作.

-(NSUInteger)supportedInterfaceOrientations {
  return UIInterfaceOrientationMaskPortrait;

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)

这是Xcode摘要页面: 在此输入图像描述

Gur*_*uru 7

有解决方案.我们可以在setupCocos2dWithOptions中设置方向.

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self setupCocos2dWithOptions:@{
        CCSetupShowDebugStats: @(YES),
        CCSetupScreenOrientation: CCScreenOrientationPortrait,
    }];

    return YES;
}
Run Code Online (Sandbox Code Playgroud)