ios - Lock App into one specific orientation in Cocos2D v3 -


i trying disable screen rotation in cocos2d-3.x, cannot figure out how. have following code in ccappdelegate:

-(bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {   setupcocos2dwithoptions:      [self setupcocos2dwithoptions:@{          ccsetupshowdebugstats: @(yes),         // run in portrait mode.         ccsetupscreenorientation: ccscreenorientationportrait,      }];      return yes; } 

the screen in portrait mode, rotates portrait upsidedown. read cocos2d uses uiviewcontroller should use apple method this?

cocos2d allows choose between "landscape" or "portrait" doesn't allow specify orientation more specific. fixed in cocos2d can modify cocos2d source code workaround. have opened github issue problem.

implementing supportedinterfaceorientations in ccappdelegate not fix issue because method implemented ccnavigationcontroller , overrides settings.

open "ccappdelegate.m" , go line 77. should see method:

-(nsuinteger)supportedinterfaceorientations {     if ([_screenorientation isequal:ccscreenorientationall])     {         return uiinterfaceorientationmaskall;     }     else if ([_screenorientation isequal:ccscreenorientationportrait])     {         return uiinterfaceorientationmaskportrait | uiinterfaceorientationmaskportraitupsidedown;     }     else     {         return uiinterfaceorientationmasklandscape;     } } 

you can change entire method support 1 orientation, e.g.:

-(nsuinteger)supportedinterfaceorientations {     return uiinterfaceorientationportrait; } 

when change method can return 1 of 4 orientations want lock game into:

uiinterfaceorientationmasklandscapeleft uiinterfaceorientationmasklandscaperight uiinterfaceorientationmaskportrait uiinterfaceorientationmaskportraitupsidedown 

that's workaround now.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -