Sunday, 2 June 2013

How to get device orientation programmatically: cocos2d

Tho get the device orientation programmatically, you can use the following code:


    if([[UIDevice currentDevice] orientation] == kCCDeviceOrientationPortrait) {
        NSLog(@"Portrait");
    }
    else if ([[UIDevice currentDevice] orientation] == kCCDeviceOrientationLandscapeLeft) {
        NSLog(@"LandscapeLeft");
    }
    else if ([[UIDevice currentDevice] orientation] == kCCDeviceOrientationLandscapeRight) {
        NSLog(@"LandscapeRight");
    }
    else if ([[UIDevice currentDevice] orientation] == kCCDeviceOrientationPortraitUpsideDown) {
        NSLog(@"PortraitUpsideDown");
    }

No comments:

Post a Comment