Reputation: 89
Hi i need to set a game in cocos2d to run only on portrait. I have checked de portrait mode checkbox in XCode project settings, also from spritebuilder, set the game to portrait. Nothing of this is working, i'm still able to rotate device orientation. Is it something thant i;m missing in order for this to work, or is it a way to set this by code? I found something linke
[director setDeviceOrientation] or [UIdevice setdeviceOrietation]
All this is deprecated in 3.x versions Thanks in advance!
Upvotes: 0
Views: 754
Reputation: 9079
I dont use sprite builder myself, but still there must be a line like this in AppDelegate.m (this is from one of my apps) :
[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),
}];
Put in your code the appropriate orientation in the setupCococ2dWithOptions
options. That should be :
CCSetupScreenOrientation : CCScreenOrientationPortrait,
Upvotes: 1