Dynamic Orientation Settings

Hi Guys, is there a way of changing and fixing the orientation after the app has started?  I have an app which I want to provide an option to how it is presented at start-up based on the users preference (and device model).

But one of the configuration options is to have the app run in Portrait Mode.  The other app options is that it will run in Landscape mode.  But I don’t want to support both modes e.g. if the user select a certain configuration type the app is fixed in Portrait Mode (just as if the Build Settings was set to this).

I can dynamically change the Config file, but can I change the Build Settings File?  Or is there an API I can use to prevent users changing the orientation…

You might want to take a look at this API:
https://docs.coronalabs.com/api/event/orientation/index.html

Hi…any progress in that topic. I need a simular function.

thx

Assuming this is for a business app…

  1. Choose a fixed orientation in build.settings.

  2. Put all objects and groups in a screen centered parent group.

  3. Based on user selected preference or app needs, rotate the parent group by 90 degrees to the alternate orientation.

  4. Treat width variables as height and vice-versa.  Easiest way to do this is to make a module that tracks the group rotation and then have helper functions in the module for things like actualContentWidth, actualContentHeight, etc.

  5. Implement your interfaces so they can be re-drawn ‘onRotate’.

This is very straightforward to code as long a you understand the constraints.

Note: If this is for a game, things get a little more complicated, but not much.  You’ll need to do the same trick with physics. and sway x for y in your gravity and other settings.  There may be some sign changes too.

You might want to take a look at this API:
https://docs.coronalabs.com/api/event/orientation/index.html

Hi…any progress in that topic. I need a simular function.

thx

Assuming this is for a business app…

  1. Choose a fixed orientation in build.settings.

  2. Put all objects and groups in a screen centered parent group.

  3. Based on user selected preference or app needs, rotate the parent group by 90 degrees to the alternate orientation.

  4. Treat width variables as height and vice-versa.  Easiest way to do this is to make a module that tracks the group rotation and then have helper functions in the module for things like actualContentWidth, actualContentHeight, etc.

  5. Implement your interfaces so they can be re-drawn ‘onRotate’.

This is very straightforward to code as long a you understand the constraints.

Note: If this is for a game, things get a little more complicated, but not much.  You’ll need to do the same trick with physics. and sway x for y in your gravity and other settings.  There may be some sign changes too.