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. [import]uid: 9371 topic_id: 4187 reply_id: 304187[/import]

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

C. [import]uid: 24 topic_id: 4187 reply_id: 13444[/import]

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

C. [import]uid: 24 topic_id: 4187 reply_id: 13445[/import]

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:

[blockcode]
local borderBottom = display.newRect( 20, display.contentHeight, display.contentWidth, 30 )
[/blockcode]

On ALL devices EXCEPT Droid it’s placed as expected, on Droid it’s placed about 100 pixels too high…

Also placing an object at the top of the screen is correct on ALL devices EXCEPT Droid, where it’s placed about 100 pixels lower!

Any help you have offer would be greatly appreciated as otherwise I shall have to ask for a refund.

A thought : How does one go about getting the ACTUAL screen size so I can place items correctly and don’t say contentHeight or contentviewableHeight as they just return whatever the height setting is in the config.lua, in this case 480. Perhaps it would be nice to have an API call that returns the REAL height and width.

I think there is a bug here, why is the placement incorrect for JUST Droid?
[import]uid: 9371 topic_id: 4187 reply_id: 13480[/import]

Carlos? [import]uid: 9371 topic_id: 4187 reply_id: 13711[/import]

Carlos? [import]uid: 9371 topic_id: 4187 reply_id: 13774[/import]

Carlos? [import]uid: 9371 topic_id: 4187 reply_id: 13827[/import]

@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… [import]uid: 7356 topic_id: 4187 reply_id: 13829[/import]

I have

[blockcode]
application =
{
content =
{
scale = “letterbox”,
width = 320,
height = 480,
fps = 60,

}
}
[/blockcode]

As per the “magic recipe” technique this ensure that the background image always fills the screen HOWEVER the placement of items on Droid are INCORRECT. I have emailed Ansca and Carlos’s personal email but still I wait for a solution!

All I want to do is place objects at the top and the bottom of the screen for iPhone AND Android. This seems to be an impossible task even using the so called “magic recipe” that says it will work on ALL devices… :frowning: [import]uid: 9371 topic_id: 4187 reply_id: 13830[/import]

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”] [import]uid: 3007 topic_id: 4187 reply_id: 13905[/import]

@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… [import]uid: 7356 topic_id: 4187 reply_id: 13913[/import]

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. [import]uid: 11393 topic_id: 4187 reply_id: 13914[/import]

@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!
[import]uid: 9371 topic_id: 4187 reply_id: 13962[/import]

This seems to be the only way to ensure the game is ‘framed’ correctly for iPhone, iPad and Android…

[blockcode]
– 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)

[/blockcode] [import]uid: 9371 topic_id: 4187 reply_id: 13977[/import]

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.] [import]uid: 11393 topic_id: 4187 reply_id: 13979[/import]

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. [import]uid: 9371 topic_id: 4187 reply_id: 13982[/import]