Device orientation question (in relation to the user changing the orientation of the device)

Hello!

I’m a newbie here to Corona development, and I appreciate the usage of a scripting language to build and test quickly!

So, here’s my question:

I’m currently building an application that includes a slideshow (via the wonderful “slideView” script provided on the website).

I was wondering how scaling the content would work in Corona depending upon the current device orientation?

At first, I thought I would just build a separate module for each orientation (similar to building different nibs in XCode, for native iOS development), but then I saw the “system.orientation” command.

Is this command executed during runtime? So, for instance, if somebody is viewing the slideshow in landscapeRight mode, then changes to “portrait”, a line containing the “system.orientation” code (in the currently running lua script) will fire?

I’d appreciate any assistance you could offer. Thank you very much! [import]uid: 10211 topic_id: 17082 reply_id: 317082[/import]

[lua]system.orientation[/lua] returns the system orientation.

landscapeLeft
landscapeRight
portrait
portraitUpsideDown

So you could set things up to respond accordingly, eg;

[lua] if system.orientation == “portrait” then
– do stuff here
end[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 17082 reply_id: 64211[/import]

Thanks, Peach! I appreciate it.
Now, how would I check for that while the application is running? Do I need a listener? And what would be the proper syntax to call that?

Thanks! [import]uid: 10211 topic_id: 17082 reply_id: 64720[/import]

yes like this

[lua]local function onOrientationChange(event)

if event.type==“landscapeLeft” then
– do stuff
elseif
– … and so on
end
end

Runtime:addEventListener( “orientation”, onOrientationChange )
[import]uid: 13632 topic_id: 17082 reply_id: 64724[/import]

Ah! Perfect!

Thanks a bunch! :smiley: [import]uid: 10211 topic_id: 17082 reply_id: 64750[/import]