Thursday, February 27, 2025
spot_img

Drive orientation in a sport with multi orientation – C++


Hello, in my sport iOS and Android I exploit Cocos2d-x 3.17.

I’m serching to view some layer in panorama (sport) and one layer in portrait (settings)

I’ve learn plenty of posts, I’ve tried rather a lot, however I nonetheless haven’t succeeded.

I can render primarily based on orientation, however I haven’t been in a position to lock a given orientation primarily based on the layer/scene proven.

on iOS I used to be attempt with some technique in RootViewController:

  • supportedInterfaceOrientations
  • viewWillTransitionToSize: (CGSize)measurement withTransitionCoordinator
  • attemptRotationToDeviceOrientation (appears to me not working)

attempt to add notification on DeviceOrientationChange (I don’t assume that’s what I’m enthusiastic about, I’ve to pressure an orientation primarily based on the layer/scene proven)

attempt windowScene requestGeometryUpdateWithPreferences (I nonetheless can’t get it to work correctly, however that is iOS 16+, and I don’t wish to exclude older units)

Does anybody have any options for this example?
I’m attempting this:

  • Answer 1:
    UIInterfaceOrientationMaskAll in supportedInterfaceOrientations in RootViewController.mm

I haven’t discovered find out how to programmatically lock the rotation primarily based on the scenes proven

  • Answer 2:
    UIInterfaceOrientationMaskLandcape at launch in supportedInterfaceOrientations in RootViewController.mm

Then I wish to change it at runtime.
Nonetheless, if I set it this manner within the RootViewController, the supportedInterfaceOrientations technique is just not referred to as after I put the gadget in portrait.

  • Answer 3:
    Strive making a brand new UIViewController for the web page in portrait, nevertheless it appears that evidently the RootViewController settings stay.
    Perhaps one thing like this:
    RootViewController → MaskAll
    GameViewController → MaskLandscape
    SettingsViewController → MaskPortrait
    Additionally, I assume, I ought to “transfer” the GLView to the proper viewController.

I’m specializing in iOS now, then Android I assume can have one other customized dealing with.

Thanks for assist
Don

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles