cocos2d v3.x禁用设备旋转,仅设置纵向模式

时间:2014-12-08 11:55:32

标签: objective-c cocos2d-iphone spritebuilder

您好我需要在cocos2d中设置游戏才能在肖像上运行。 我在XCode项目设置中检查了de portrait mode复选框,也是从spritebuilder,将游戏设置为肖像。 这些都没有用,我仍然可以旋转设备方向。 是不是因为这个问题而失踪?为了让它起作用,或者它是一种设置方法 通过代码? 我发现了一些内容

[导演setDeviceOrientation]    要么    [UIdevice setdeviceOrietation]

所有这些都在3.x版本中弃用 提前致谢!

1 个答案:

答案 0 :(得分:1)

我自己不使用精灵构建器,但在AppDelegate.m中仍然必须有这样的行(这来自我的一个应用程序):

    [self setupCocos2dWithOptions:@{
        // Show the FPS and draw call label.
        CCSetupShowDebugStats : @(YES),

        // More examples of options you might want to fiddle with:
        // (See CCAppDelegate.h for more information)
        // Use a 16 bit color buffer:
        // CCSetupPixelFormat: kEAGLColorFormatRGB565,

        // Use a simplified coordinate system that is shared across devices.
        CCSetupScreenMode : CCScreenModeFixed,

        // Run in landscape mode.
        CCSetupScreenOrientation : CCScreenOrientationLandscape,

        // Run at a reduced framerate.
        CCSetupAnimationInterval : @(1.0 / 30.0),

        // Run the fixed timestep extra fast.
        CCSetupFixedUpdateInterval : @(1.0 / 60.0),

        // clipping with stensil
        CCSetupDepthFormat : [NSNumber numberWithUnsignedInt:GL_DEPTH24_STENCIL8_OES],
        // Make iPad's act like they run at a 2x content scale. (iPad retina 4x)
       //       CCSetupTabletScale2X: @(YES),
}];

setupCococ2dWithOptions选项中添加适当方向的代码。那应该是:

            CCSetupScreenOrientation : CCScreenOrientationPortrait,