What am I missing, Orientation Change...

So in the Corona Simulator, and the xCode simulator, when I rotate the device the screenWith and contentWidth never seem to change.... Shouldn't they? Or do I need to do the math myself, and reposition stuff?

Thanks,
Scott.

see Orientation example in interface in sample code

:)

Is there a way to do that and move the status bar as well?? I've noticed that the orientation demo doesn't work properly if you specify supported orientations in build.settings.

-Matt
W2MD

You'd want to experiment a bit with build.settings if it isn't working as intended; try using just one orientation, try using all 4, etc, see what happens.

For the status bar, I'm not certain - as most people remove it the orientation sample may not have been written with it in mind. (We can't move the status bar without proper rotation, obviously.)

@drbigfresh: I kinda agree with you:

If I set the build.settings orientation mode from a new app to default: landScape, does that mean that my deviceWidth is also the landScapeWidth instead of the portraitWidth?

I tried this and it seems it's not the case.

It's a little confusing making an app landScape-mode and then find out that you have to recreate your app to Portrait-mode and then set the rotation of each object 45 degrees.

It feels unnatural.

Maybe someone can lighten us up on creating a app with landScape as the default orientation and place objects to landScapeWidth and landScapeHeight dimensions?

@peach pellen: I will study your link when I'm at home. Did a quick scan over it, but it doesn't seem to refer to default orientation (landscape) :-)

Ignore this, didn't read the question properly and wrote something irrelevant.

-- Chris

Peach,

Messing around with build.settings only seems to make things worse.

In the last few days, I've done quite a bit of experimenting with the orientation sample code and the tutorial made by burton's media group, and while they do work, they make everything 4 times more complicated. In order to rotate an entire screen full of display objects, you have to hard code their coordinates for all four positions and well as put together the logic for rotating in the correct direction in every situation (including 180 degree rotations whenever the device is flipped).

This seems like something that would involve a significant work-around that must be incorporated from the very beginning of the project. The amount of time and energy doesn't seem to match the value of the result.

Is there any native corona element like this coming in the foreseeable future? The current (instant) change in orientation that occurs naturally to corona apps (with the black border rotating all by itself) works great, but would be vastly improved by the rest of the app moving with that black border.

Also, I just found this. http://developer.anscamobile.com/code/proper-orientation-rotation-animation#comment-51173
But it doesn't support 90 degree rotations, and I haven't had time to look it over thoroughly. Is it going to be worth expanding this rotationfix.lua code to include 90 degree rotations? Or should I wait on you guys to add it into the native corona functionalities?

Thanks for your input,
-Matt
W2MD

actually you need two separate images one for portrait (320x480) and one for landscape (480 x 320) as you want to give support for all orientation now you need to code for two orientation portrait and landscape all the orientation changes with 180 degree rotation will be handle automatically but for 90 degree rotation you have to manage through your code also when you specify all four orientation in build.setting file it means you get two mode faceUp and faceDown for free (if you guys have seen the demo in interface example you already knows that) actually faceUp or faceDown = last orientation

you can get this orientation by putting ur device on table make sure it is not tilted to handle this modes you can refer this post

http://developer.anscamobile.com/forum/2011/05/09/face-orientation-bug

but it is sure that you need two saperate images and separate coordination for landscape and portrait

also the link provided above rotationfix.lua is to handle this situation as mentioned over there

"content on the OpenGL canvas of Corona SDK rotated instantly while rest of the native UI elements (status bar, dialogs, etc) rotated with an animation following it"

if you want to test put any images and some native element like textbox and rotate ur device u will find the difference

i hope its clear now if not feel free to post

:)

@w2md: In my opinion programming in default landscapeMode feels like programming in a buggy portraitMode.

It looks like objects dimensions (width/height/x/y) sometimes live there own live. Device width/height/x/y going portait etc.

This said, I have to say I'm not a guru, but also not a noob :-)

PS. I have a small question:
In landscapeMode, can the deviceWidth and deviceHeight be this: 1280x768?
I have a Androidtablet with a 1280x768 screen.

PPS. Peach, enlighten us :-)

Tim,

You can set the width and height to whatever you want in config.lua and corona will automatically scale everything to those specifications (with your choice of letterbox, zoomeven, or zoomstretch). However, 1280x768 would give quite a bit of stretching/leftover endspace on devices with android devices or a different shape. Your best bet seems to be to pick a moderate shape and size your app to that.

As far as the landscape mode feeling buggy, I agree it's a little weird, but if you are defaulting to landscape you could just switch your width and height and it will adjust properly. It becomes weirder when you do these 90 degree rotations, because then display.contentWidth doesn't adjust with the rotation and neither will your objects sizes and coordinates.

Best,
-Matt
W2MD

@w2md: Thanks for your reply!

I now have 2 questions left:
Can you recommended a deviceWidth/deviceHeight close to 1280x768 that should work properly?

Should this be a solution for defaulting to landscape?:

1
2
3
4
5
6
7
8
9
--change default orientation
deviceWidth = display.contentHeight
deviceHeight = display.contentWidth
originX = display.screenOriginY
originY = display.screenOriginX
 
--create a fullwidth/fullheight background
local bg = display.newRect(originX,originY,deviceWidth,deviceHeight)
bg:setFillColor(255,255,255)

Tim,

Your are close.

When I said to switch the width and height I was actually talking about in the config.lua file.

config.lua normally looks something like this (for iPad):

1
2
3
4
5
6
7
8
9
10
11
         application = 
        {
                content =
                {
                        width = 768,
                        height = 1024,
                        scale = "letterbox",
                },
        }
 
 

@w2md: Thanks for all your help!
I'll go with the iPad dimensions then, since they've got the lead indeed :-)

It's a medical app (landscape on a tablet) i'm creating, so I want to be sure if my preperations are going in the right direction ;-)

views:2662 update:2011/10/11 15:24:38
corona forums © 2003-2011