Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Allowing Landscape Orientation Selectively, Possible?
Started by sandeep.kharkar Apr 23 2015 07:04 PM

8 replies to this topic
orientation landscape

Best Answer Rob Miracle , 23 April 2015 - 07:20 PM

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

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

sandeep.kharkar

[GLOBAL: userInfoPane.html]
sandeep.kharkar
  • Observer

  • 7 posts
  • Corona SDK

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

 



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,786 posts
  • Enterprise

  Best Answer

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



[TOPIC: post.html]
#3

sandeep.kharkar

[GLOBAL: userInfoPane.html]
sandeep.kharkar
  • Observer

  • 7 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

sandeep.kharkar

[GLOBAL: userInfoPane.html]
sandeep.kharkar
  • Observer

  • 7 posts
  • Corona SDK

Thanks horacebury!



[TOPIC: post.html]
#6

corona273

[GLOBAL: userInfoPane.html]
corona273
  • Contributor

  • 482 posts
  • Enterprise

<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.



[TOPIC: post.html]
#7

corona273

[GLOBAL: userInfoPane.html]
corona273
  • Contributor

  • 482 posts
  • Enterprise

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/



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,786 posts
  • Enterprise

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



[TOPIC: post.html]
#9

corona273

[GLOBAL: userInfoPane.html]
corona273
  • Contributor

  • 482 posts
  • Enterprise

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. :(
 
 
It would be great if you could respond.



[topic_controls]
[/topic_controls]