Allowing Landscape Orientation Selectively, Possible?

I want to only allow my app to auto switch to landscape mode during certain screens.Is it possible to allow the landscape mode selectively during the app’s run, or is it all or nothing?

If this is possible can you point to any samples for this?

Thanks,

Sandeep

Corona can automatically support either landscape or portrait or allow us to auto rotate for you.  But this is all or nothing.  For what you’re doing you would want a fixed orientation and then when you need the other, then you will need to draw your scene rotated by 90 degrees.

Rob

Rob,

Thanks for that clarification. Given the situation I have a followup question.

Are there methods I can use to draw text that is rotated?

Can I anchor a newText at the middle and rotate it?

Thanks for your time.
~Sandeep

EDIT: Looks like display objects have a rotate API. I will try that.

What you can do is just used a fixed orientation and detect device orientation events. If the device/orientation you detect is approved, then fire an event to let you scene know the change has occurred (you’d have to do this anyway) and provide calculated screen width and height by swapping those values round.

Thanks horacebury!

Corona can automatically support either landscape or portrait or allow us to auto rotate for you.  But this is all or nothing.  For what you’re doing you would want a fixed orientation and then when you need the other, then you will need to draw your scene rotated by 90 degrees.

Rob

Rob,

Thanks for that clarification. Given the situation I have a followup question.

Are there methods I can use to draw text that is rotated?

Can I anchor a newText at the middle and rotate it?

Thanks for your time.
~Sandeep

EDIT: Looks like display objects have a rotate API. I will try that.

What you can do is just used a fixed orientation and detect device orientation events. If the device/orientation you detect is approved, then fire an event to let you scene know the change has occurred (you’d have to do this anyway) and provide calculated screen width and height by swapping those values round.

Thanks horacebury!

<horacebury>: Hi there! You wrote in April: “What you can do is just used a fixed orientation and detect device orientation events.”

I tried that by changing build.settings to:

default = "portrait", supported = { "portrait" },

But then the runtime resize events never fire. So I love your idea of handling this programmatically, but I don’t believe Corona supports this method? I suspect you’ve dealt with orientation changes more than I have, so I may be missing something, and appreciate any guidance you or Rob can provide.

PS: What I’d like to do is handle portrait and landscape orientation changes programmatically rather than have them fixed at build time. So then in an in-app preference menu I can allow or disallow handling of orientation changes. Some users really hate orientation changes if they’re reading something onscreen and tilt the device a little, especially because Corona’s webview implementation is not robust: https://forums.coronalabs.com/topic/50115-cant-believe-that-webview-still-doesnt-scaleseriously/

You may have to support all orientations and then select which orientation events to support to  handle and how to handle them. I can see setting your project to a single orientation where you wouldn’t get orientation events.

Rob

Rob: Can you elaborate? It seems to me that I have a matrix of four options:

  1. Multiple orientations in build.settings and runtime resize listener added
  2. Multiple orientations in build.settings and runtime resize listener not added
  3. Single orientation in build.settings and and runtime resize listener added
  4. Single orientation in build.settings and and runtime resize listener not added

For #1, the app works but on Android ignores the system-wide orientation lock because Corona SDK fails to pay attention to the user system-wide setting (see below). #2 the canvas resizes and the content does not change. In #3 the runtime listener is ignored. #4 works as expected.

What I am trying to do is work around the Corona SDK bug on Android that ignores the system-wide screen rotation setting. The proper solution is for Corona to fix this bug. As an interim step until your engineers fix the bug, I’d like to add an app-specific setting as a temporary fix (probably through #3?) but I do not think it is possible. :frowning:

More info on the Corona SDK bug on Android is here: https://forums.coronalabs.com/topic/59359-can-corona-fix-android-orientation-change-bug-fails-to-obey-system-preferences/

It would be great if you could respond.

<horacebury>: Hi there! You wrote in April: “What you can do is just used a fixed orientation and detect device orientation events.”

I tried that by changing build.settings to:

default = "portrait", supported = { "portrait" },

But then the runtime resize events never fire. So I love your idea of handling this programmatically, but I don’t believe Corona supports this method? I suspect you’ve dealt with orientation changes more than I have, so I may be missing something, and appreciate any guidance you or Rob can provide.

PS: What I’d like to do is handle portrait and landscape orientation changes programmatically rather than have them fixed at build time. So then in an in-app preference menu I can allow or disallow handling of orientation changes. Some users really hate orientation changes if they’re reading something onscreen and tilt the device a little, especially because Corona’s webview implementation is not robust: https://forums.coronalabs.com/topic/50115-cant-believe-that-webview-still-doesnt-scaleseriously/

You may have to support all orientations and then select which orientation events to support to  handle and how to handle them. I can see setting your project to a single orientation where you wouldn’t get orientation events.

Rob

Rob: Can you elaborate? It seems to me that I have a matrix of four options:

  1. Multiple orientations in build.settings and runtime resize listener added
  2. Multiple orientations in build.settings and runtime resize listener not added
  3. Single orientation in build.settings and and runtime resize listener added
  4. Single orientation in build.settings and and runtime resize listener not added

For #1, the app works but on Android ignores the system-wide orientation lock because Corona SDK fails to pay attention to the user system-wide setting (see below). #2 the canvas resizes and the content does not change. In #3 the runtime listener is ignored. #4 works as expected.

What I am trying to do is work around the Corona SDK bug on Android that ignores the system-wide screen rotation setting. The proper solution is for Corona to fix this bug. As an interim step until your engineers fix the bug, I’d like to add an app-specific setting as a temporary fix (probably through #3?) but I do not think it is possible. :frowning:

More info on the Corona SDK bug on Android is here: https://forums.coronalabs.com/topic/59359-can-corona-fix-android-orientation-change-bug-fails-to-obey-system-preferences/

It would be great if you could respond.