Search code examples
iphonecocos2d-iphone

Cocos2d - Setting Device/Screen Orientation


I am new to the cocos2d API and have noticed that there are a few ways to set the screens orientation within the templates. I have not been able to figure out the correct way to set my orientation to LandscapeRight and keep it that way throughout the entire game. How do I change my orientation so that it maintains LandscapeRight? Any help is appreciated. Thank you!


Solution

  • Modify GameConfig.h from the cocos2d template.

    #define GAME_AUTOROTATION kGameAutorotationNone
    /* original code is kGameAutorotationUIViewController. */
    

    And modify AppDelegate.m as well.

    #if GAME_AUTOROTATION == kGameAutorotationUIViewController
        [director setDeviceOrientation:kCCDeviceOrientationPortrait];
    #else
        [director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
        /* original code is "Left". */
    #endif