Hi, in my game iOS and Android I use Cocos2d-x 3.17.
I’m serching to view some layer in landscape (game) and one layer in portrait (settings)
I’ve read a lot of posts, I’ve tried a lot, but I still haven’t succeeded.
I can render based on orientation, but I haven’t been able to lock a given orientation based on the layer/scene shown.
on iOS I was try with some method in RootViewController:
- supportedInterfaceOrientations
- viewWillTransitionToSize: (CGSize)size withTransitionCoordinator
- attemptRotationToDeviceOrientation (seems to me not working)
try to add notification on DeviceOrientationChange (I don’t think that’s what I’m interested in, I have to force an orientation based on the layer/scene shown)
try windowScene requestGeometryUpdateWithPreferences (I still can’t get it to work properly, but this is iOS 16+, and I don’t want to exclude older devices)
Does anyone have any solutions for this situation?
I’m trying this:
- Solution 1:
UIInterfaceOrientationMaskAll in supportedInterfaceOrientations in RootViewController.mm
I haven’t found how to programmatically lock the rotation based on the scenes shown
- Solution 2:
UIInterfaceOrientationMaskLandcape at launch in supportedInterfaceOrientations in RootViewController.mm
Then I would like to change it at runtime.
However, if I set it this way in the RootViewController, the supportedInterfaceOrientations method is not called when I put the device in portrait.
- Solution 3:
Try making a new UIViewController for the page in portrait, however it seems that the RootViewController settings remain.
Maybe something like this:
RootViewController → MaskAll
GameViewController → MaskLandscape
SettingsViewController → MaskPortrait
Also, I guess, I should “move” the GLView to the correct viewController.
I’m focusing on iOS now, then Android I guess will have another custom handling.
Thank you for help
Don