Orientation Axes and Dimension Confusion

Hi my team is creating a series of minigames in a single game application. We use the storyboard API to switch between minigames and menus.

One confusing problem that has arisen is that everytime the device is rotated in the simulator, the width and height changes to the perceived width and height. As in the width in landscape becomes the height in portrait. This makes it very confusing to code for as I would assume the width and height to be a device constant and not changed as and when the SDK likes.

This is all okay after we fix the default orientation in build.settings to landscapeRight to fix the reference axes and use system.orientation to check the correct width and height value we need. We tested on the simulators for all devices and the app seems to work fine.

However, when I built the game and launched it on my HTC Desire Z, it would seem that the width and height values are fixed regardless of orientation of the device, which is different from the simulated result. This caused my entire scene to be squashed and stretched out of proportion. Granted I can add an additional layer of code to check where I am running on to obtain the correct width and height values, but shouldn't there be a more intuitive method to do this? And is this fixed and dynamic width/height problem only specific to my device?

Most importantly, is there a way to set a default orientation for each scene in the storyboard? Some of our minigames are in portrait and some in landscape, which requires us to constantly rotate items to fit the orientation.

Are you using display.viewableContentWidth or display.contentWidth?

I'm using display.contentWidth. I just did a simulator test with the following code:

local function onChange(event)
        print(display.viewableContentWidth .. " " .. display.viewableContentHeight)
        print(display.contentWidth .. " " .. display.contentHeight)
Runtime:addEventListener("orientation", onChange)
views:1349 update:2011/12/28 9:26:54
corona forums © 2003-2011