[Corona Simulator] Same resolution for all devices?

Hi the Coronians,

I just noticed something that I think wrong about Corona Simulator.

First, when I write this code :

print(display.contentHeight) print(display.contentWidth)

then launch the app, here’s what I get:

480 320

Problem is, if I change the device with “View as” option, I get exactly the same figures, no matter what device I’m on (Galaxy SIII, iPhone, Kingle, etc…). Are they not supposed to have different resolutions?

This consequently add some display problems when I code using these display.contentHeight and _display.contentWidth, _For example I will have a different results on different devices with that piece of code :

local background = display.newImage( "BG.png" ) background.height = display.ContentHeight background.width = display.ContentWidth

On Galaxy SIII and other, I still have black borders on the top and bottom.

I don’t think that’s normal, so I’m turning on you.

Any idea (I precise that I’m on Windows 8.1, if that can help)?

Thanks in advance,

Thomas

I believe it works in tandem with what you’ve setup in config.lua; i.e you’re probably using a 480x320 scheme for all devices?

you need to make sure that in your config file you have @2x and @4x graphics set up correctly (as well as having BG@2x.png and BG@4x.png graphics)

have a read of these 2 tutorials, they helped me out a lot

Ultimate Config

Modernizing the Config

That’s right, the width and height were set 480x320 in the config.lua file.

It’s annoying cause this is set like that automatically when creating a new project, and in the tutorials they never mention it, so when trying to redo the tutos it doesn’t work the same.

Anyway, thanks to both of you, and RJ5 I’m gonna check those tuto that should be helpful. :wink:

display.contentWidth and contentHeight return the values defined in config.lua for the width and height of the device (adjusted for portrait or landscape, config.lua is always written in portrait mode).  display.pixelWidth and display.pixelHeight return the actually height and width of the device.   I think we have a scale API but you can compute the scale factor by dividing the pixelWidth by the contentWidth.

Rob

I didin’t know this display.pixelWidth/Height command. Thanks for the tip. :wink:

I believe it works in tandem with what you’ve setup in config.lua; i.e you’re probably using a 480x320 scheme for all devices?

you need to make sure that in your config file you have @2x and @4x graphics set up correctly (as well as having BG@2x.png and BG@4x.png graphics)

have a read of these 2 tutorials, they helped me out a lot

Ultimate Config

Modernizing the Config

That’s right, the width and height were set 480x320 in the config.lua file.

It’s annoying cause this is set like that automatically when creating a new project, and in the tutorials they never mention it, so when trying to redo the tutos it doesn’t work the same.

Anyway, thanks to both of you, and RJ5 I’m gonna check those tuto that should be helpful. :wink:

display.contentWidth and contentHeight return the values defined in config.lua for the width and height of the device (adjusted for portrait or landscape, config.lua is always written in portrait mode).  display.pixelWidth and display.pixelHeight return the actually height and width of the device.   I think we have a scale API but you can compute the scale factor by dividing the pixelWidth by the contentWidth.

Rob

I didin’t know this display.pixelWidth/Height command. Thanks for the tip. :wink: