【问题标题】:cocos2d v3.x Disable device rotation, set portrait mode onlycocos2d v3.x 禁用设备旋转,仅设置纵向模式
【发布时间】:2014-12-08 11:55:31
【问题描述】:

您好,我需要在 cocos2d 中设置一个游戏以仅在纵向上运行。 我已经检查了 XCode 项目设置中的肖像模式复选框,也来自 spritebuilder,将游戏设置为肖像。 这一切都不起作用,我仍然能够旋转设备方向。 它是不是我缺少的东西,为了让它工作,或者它是一种设置它的方法 通过代码? 我发现了一些东西

[导演setDeviceOrientation] 或者 [UIdevice setdeviceOrietation]

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

【问题讨论】:

    标签: objective-c cocos2d-iphone spritebuilder


    【解决方案1】:

    我自己不使用 sprite builder,但在 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,
    

    【讨论】:

    • 感谢您的回答,我尝试了类似的方法,但如果我把 [self setupCocos2dWithOptions:@{ //CCSetupScreenOrientation: CCScreenOrientationPortrait, //}];游戏变成黑屏。将尝试使用您的配置感谢您的帮助!
    • 查找现有的设置行并添加选项。在应用的生命周期中,您只能调用一次。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多