Reputation: 1223
I have a Start-Menu scene, which I want to be shown in the Portrait Orientation. The rest of the game is in the standard landscape orientation.
I've tried following in the scenes init method:
[[CCDirector sharedDirector] setDeviceOrientation:kCCDeviceOrientationPortrait];
and
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationPortrait];
My question is, how can I switch Screen-Orientations during runtime?
thanks in advance! Alex
Upvotes: 0
Views: 1811
Reputation: 94683
I'm not sure about doing something directly I. cocos2d. But you can put everything in a single UIView and then do a 90 degrees rotation transform on it. There is a private API to force rotate the device but it is agains app store rules to use it and it can be unpredictable too.
Upvotes: 0
Reputation:
You need to use the following code in the view controller you want to be in landscape:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationLandscapeLeft;
}
That code will force the view controller to only display in landscape-left. You return whichever orientations you want to support.
e.g.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationLandscapeLeft && UIInterfaceOrientationLandscapeRight;
}
I know you are using cocos2d but this code should still work fine in your view controller.
Upvotes: 1