This what I did to get my app to run on every device out there (it is landscape only) - see the free (Lite) version at https://play.google.com/store/apps/details?id=net.medved.games.rescuelite
-
Use letterbox, set coords to 1024x768 (IPad)
-
In my code, define screen edge coords:
local scX1 = display.screenOriginX
local scY1 = 0
local scX2 = scX1+math.abs(scX1)\*2+display.contentWidth
local scY2 = scY1+display.contentHeight-1
obviously width is scX2-scX1+1 and height is scY2-scY1+1
Note that scX1 can be negative
-
Backgrounds: for some that can be done that way (like the ocean/sky), I load the 1024x768 background and stretch it into the screen. For others, I have the extra left and right extensions - so I load the main background in the middle and supplement it on left and right with extra images.
-
Gameplay, positioning of objects on screen etc is all done dynamically off the sc* variables above.
-
The hard part is setting the size of some UI objects. Obviously, stuff that needs finer finger touches (like input wheel field) needs to be a reasonable physical size on the screen, and that is hard to do without knowing what the DPI is on the device. So I did it the hard way. See:
https://github.com/ricardograca/android-devices-list (and thank you ricardo)
obviously the list cannot ever be complete, but it is pretty comprehensive, and I keep adding to it. I use the inchesDiagonal to figure out the size multiplier for the UI elements that I want to keep a particular physical size. If you run the app I gave you above on a smaller phone and on an iPad you will see that the input UI elements’ size changes to accommodate the smaller device.
I tested this on a bunch of devices - from the original Droid to iPad3, various Android tablets etc. It works and fills up the whole screen on all of them. For iPhone5 I just included the new Default screen in the build and I presume it will work as well. [import]uid: 160496 topic_id: 31106 reply_id: 124617[/import]