2

I am looking for a way to change IOS device orientation when a scene loads.

There are some questions asked in this direction but no concrete answers for v3.

I have 3 scenes, one should be in portrait while other 2 in landscape mode after a button is pressed from main menu scene (in portrait).

Any ideas on how to achieve this and go back and forth between orientations from within scenes?

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation method is doesn't work per scene. For instance you can add orientations for all scenes under it in appDelegate but not in specific scenes. Like Gamelevel 1 play in Portrait mode, Game level 2, play in landscape mode.
ganesh
  • 166
  • 3
  • 10
  • Have you tried shouldAutorotateToInterfaceOrientation? – Alok Rao Apr 10 '14 at 06:32
  • display a "please rotate device" image or label and wait for the user to comply – CodeSmile Apr 10 '14 at 07:39
  • @LearnCocos2d, so you are saying I should support both portrait and landscape orientations for all scenes? and user will rotate the device to play in correct mode? I don't think this solves my issue. I need scene A in portait only and scene B in landscape only. Even if user rotates device, it shouldn't rearrange screen elements. Is it possible to achieve in cocos2d v3? – ganesh Apr 10 '14 at 12:43
  • CCDirector is a UIViewController class so you may have to look into modifying that. Aside from that, I find apps (and particularly games) that force you to rotate your device more than on the initial launch pretty annoying. You'll also rarely find an app that does that in the top 100 lists for the same reason with the exception of apps that have this as their core function (ie maps app that rotates the map according to your heading). – CodeSmile Apr 10 '14 at 14:09
  • But I don't want all scenes to work in both portraits but for each scene, I want to set a default & fixed portrait. I agree with you that asking a user to change the orientation isn't a good idea. Thats why I want scene to do it on it's own upon loading. I didn't understand what I need to change in UIViewController/CCDirector class to accomplish this. Also, isn't there single UIViewcontroller in cocos2d? So it will impact all scenes. Can you please guide me? Stuck for days on this. :( Thx – ganesh Apr 11 '14 at 03:21
  • This should help you out. I did it a few months ago. [cocos2d v3 reorient screen during app use][1] [1]: http://stackoverflow.com/questions/22353111/cocos2d-v3-re-orient-screen-during-app-use – Lagoo87 Apr 16 '14 at 00:01

0 Answers0