2011-12-30 7 views
1

下のコンテンツを表示すると、横向きモードで自動回転することができます。cocos2dでポートレートモードで自動回転を設定するには?

それでは、ポートレートモードで自動的に回転する方法は?

設定方法は?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

    // 
    // There are 2 ways to support auto-rotation: 
    // - The OpenGL/cocos2d way 
    //  - Faster, but doesn't rotate the UIKit objects 
    // - The ViewController way 
    // - A bit slower, but the UiKit objects are placed in the right place 
    // 

#if GAME_AUTOROTATION==kGameAutorotationNone 
    // 
    // EAGLView won't be autorotated. 
    // Since this method should return YES in at least 1 orientation, 
    // we return YES only in the Portrait orientation 
    // 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 

#elif GAME_AUTOROTATION==kGameAutorotationCCDirector 
    // 
    // EAGLView will be rotated by cocos2d 
    // 
    // Sample: Autorotate only in landscape mode 
    // 
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
     [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]; 
    } else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) { 
     [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft]; 
    } 

    // Since this method should return YES in at least 1 orientation, 
    // we return YES only in the Portrait orientation 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController 
    // 
    // EAGLView will be rotated by the UIViewController 
    // 
    // Sample: Autorotate only in landscpe mode 
    // 
    // return YES for the supported orientations 

    return (UIInterfaceOrientationIsLandscape(interfaceOrientation)); 

#else 
#error Unknown value in GAME_AUTOROTATION 

#endif // GAME_AUTOROTATION 


    // Shold not happen 
    return NO; 
} 

答えて

1

だけにshouldAutorotateToInterfaceOrientationを変更した場合:

return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown) 

それが上下逆さまに肖像画を除くすべての方向のために回転します。

関連する問題