Simulator : Add ability to specify the resolution/screen size

I'm building for Android and the two devices I'm currently testing for are 320 * 240 and 480 * 800.

It would be nice if you could specify in the simulator different screen resolutions so you can really see what the app will look like on different target devices.

Hmm... does build.settings/config.lua not work for you?

C.

Hmm... does build.settings/config.lua not work for you?

C.

I'm getting increasingly more and more frustrated with this. My basic problem is that I'm trying to ensure that my game looks 'correct' on Android devices AND iPhone/iPad devices.

I've tried the 'magic recipe' as discussed here...

http://blog.anscamobile.com/2010/11/content-scaling-made-easy/

So far so good. The background image scales to fill the screen on all devices.

HOWEVER...

I want to place a 'ground' physics object at the bottom of the screen so do this:

1
local borderBottom = display.newRect( 20, display.contentHeight, display.contentWidth, 30 )

Carlos?

Carlos?

Carlos?

@dweezil

What scale type do you have in config.lua? If you have "letterbox", for example, ipad have blank stripes on top and bottom of the screen (as it has taller screen than iphone). Maybe it is the same for Droid.

Beyond this, I totally agree that we should have access to the actual device resolution. We need it for other things too...

I have

1
2
3
4
5
6
7
8
9
10
11
application =
{
        content =
        {
                scale = "letterbox",
                width = 320,
                height = 480,
                fps = 60,
         
        }
}

Hi, dweezil. You still need to decide how you want to handle different aspect ratios. There's no "magic" solution, since there are several different things you might want, depending on context.

The Android screens are tall and skinny compared to the iPhone, so either you crop some iPhone content, or you have extra content on Android. In many cases, the "extra" content can be filler (which is easiest), but in your case you want something at the bottom of the screen. That's your choice.

To find the bottom of the screen on any device, use display.viewableContentHeight. That will tell you the position of the bottom of the screen, in the coordinates used by your app.

Note that the ACTUAL screen size wouldn't help you with this problem, since an app using content scaling is working in SCALED coordinates, which makes the actual device pixels meaningless. Think of it as "virtual pixels" rather than physical pixels.

[Edit: changed "display.contentHeight" to "display.viewableContentHeight"]

@dweezil

If you just want to provide your assets in only 1 resolution (the same assets for all devices) then the solution I would clearly choose is to go with:
1) no base content in config.lua (delete width,height,scale) and 2) relative positioning (using a percentage of display.contentWidth and Height wherever you want to set a x,y coordinate)

Try it, it works...

dweezil,

I had the same issue. I saw no purpose in extending the background which wasn't really a usable part of the screen.

I resolved it by drawing creating a display group with two black rectangles. One rectangle was placed at coordinates (0,-1) to (display.contentWidth,-50) and the other at (0,display.contentHeight+1) to (display.contentWidth, display.contentHeight+50).

You may need to keep pushing the group to the forefront at the end of every draw cycle, which is easy now with object:toFront().

@Corona Team: Would be good if there was an option for this to be done automatically.

@Evank

You say...

display.viewableContentHeight just returns whatever is set in config.lua!

@bedhouin

And you are saying use width and height in config.lua? Also there should be no need to push the filler objects to the front each screen update, just place them in a layer that's at the front.

Also when you say usable part of the screen, of course it's usable if you target the devices real size, for example 480 * 800.

@Ansca

I would really like to see a REAL project of how to do it, as I'm now very confused by the whole thing. So as I understand it you cannot place an object at the bottom of the screen and the top of the screen for all devices. Is that right? If not PLEASE COULD SOMEONE SHOW ME AN ACTUAL WORKING PROJECT!?!?!?!

Seems to me you cannot even have a target build for Android and a different project to build for iPhone as the Android devices are all different in sizes. So it seems that the answer is to target the iOS devices and compromise the Android ones. Is that what others do? Seems mad as all those Android users will be thinking hell this game has black gaps top and bottom. And iPad users thinking hell there are black gaps on the left and right!

This seems to be the only way to ensure the game is 'framed' correctly for iPhone, iPad and Android...

1
2
3
4
5
6
7
8
9
10
11
-- BLOODY FILLERS!
 
local fillTop = display.newRect(0,-1, display.contentWidth,-50)
local fillBottom = display.newRect(0,display.contentHeight+1, display.contentWidth, display.contentHeight+50)
local fillRight = display.newRect(display.contentWidth, 0, display.contentWidth+50, display.contentHeight)
local fillLeft = display.newRect(-1, 0, -50, display.contentHeight)
 
fillTop:setFillColor(0, 0, 0)
fillBottom:setFillColor(0, 0, 0)
fillLeft:setFillColor(0, 0, 0)
fillRight:setFillColor(0, 0, 0)

dweezil,

As far as I'm concerned it's not a usable portion of the screen if dynamic scaling is used. It's only a usable portion of the screen if I write specifically for that target resolution.

It actually has nothing to do with resolution, and everything to do with aspect ratios. When different aspect ratios come into play there will never be a magical solution - there must be extra code to cater for the different ratios and lots of code at that.

It happens with video formats all of the time, maybe your TV or player can scale to the aspect ratio of the 4:3, 16:9, 16:10 display but not without distortion or clipping. Otherwise it defaults to horizontal or vertical boxing.

The source will always have a fixed aspect ratio and the display will always have a fixed aspect ratio. Unless you redraw the source to match the display, you will never get a perfect fit.

With that in mind I find filler rectangles to be a rational and acceptable compromise, although I would prefer if it was done by default.

edit: [No I used display.contentWidth/Height within the lua code to draw the rectangles to screen. Same as filler code you posted.]

Thanks. I've finally come to realise that compromises have to be make in order to target multiple platforms/devices.

The most practical solution seems to be use dynamic scaling and accept the fact that black edges are par for the course.

views:3858 update:2011/9/18 20:20:08
corona forums © 2003-2011