config lua for all devices

Hi Finally my app was approved.

It’s on the app store ready for sale!

Thanks God and all of you guys for your help.

I now have 3 apps in the app store.

All for iPad.

I think it’s time to start learning how to do an app for all devices.

I went to a tutorial on corona labs

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

and I copy this config.lua

system.getInfo("model") if ( string.sub( system.getInfo("model"), 1, 4 ) == "iPad" ) then application = { content = { width = 360, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" and display.pixelHeight \> 960 ) then application = { content = { width = 320, height = 568, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } end

And I only have an image for the background in main.lua

-- this is to practice local background = display.newImage ("bg1.png")

the image is 768 px X 1024 px

I was expecting to see the background fine.

but I see the image “larger”

I don’t see the right size in any device. (iPad, iPhone, 4 5 or 3)

the config.lua must need something else.

and this is all I have in build.settings

local whichWay = "portrait" -- set this to portrait or landscape ---------------------------------- local oDefault = "landscapeRight" local oSupported = {"landscapeLeft","landscapeRight"} if whichWay == "portrait" then   oDefault = "portrait"   oSupported = {"portrait","portraitUpsideDown"} end   settings = {   orientation =   {     default = oDefault,     supported =     {       oSupported[1], oSupported[2]     },   },   iphone =   {     plist =     {       UIApplicationExitsOnSuspend = false,       UIPrerenderedIcon = true,       UIStatusBarHidden = true     },   }, }

Thanks for your help.

By the way the 3 apps are:

– Piano for kids level 1

– Guitar for kids level 1

– How to make an app for beginners

Victor, please don’t take this wrong, but please re-read the blog post all the way through.  It talks about this specific issues.  You have two things going on.

First you use display.newImage() instead of display.newImageRect().  The later is the one that reacts to the scale of the device to pick the best quality image for the device.  The blog post also covers how you have to make oversized backgrounds that “bleed” off the screen so that it covers areas regardless of the shape of the device.

With this ultimate file you must
First: use display.newImageRect()
Second: this file configures app in this way that you must always give half of dimension when writing width and height parameters.

Okay Rob, and Piotrz, Thanks.

I think this works if you have a background like sky, or clouds, or just colors in the back.

but if I want to have a “fix” background.

Like the image of a pinball machine, where the edge of the machine is the ending of the background.

and that image will be different for each device.

how do I do that?

do I have to include 5 or 6 different sizes of the same image, and the config.lua will choose the “correct” one?

and also what do you mean by --“give half of dimension when writing width and height parameters.”–

Thanks

If your background has design elements that won’t work if part of the background bleeds off the screen or if certain elements have to be in the right place based on the screen shape, then yes, you have to include multiple backgrounds and use “if” statements to determine which one to load.

I got it, thanks Rob.

Victor, please don’t take this wrong, but please re-read the blog post all the way through.  It talks about this specific issues.  You have two things going on.

First you use display.newImage() instead of display.newImageRect().  The later is the one that reacts to the scale of the device to pick the best quality image for the device.  The blog post also covers how you have to make oversized backgrounds that “bleed” off the screen so that it covers areas regardless of the shape of the device.

With this ultimate file you must
First: use display.newImageRect()
Second: this file configures app in this way that you must always give half of dimension when writing width and height parameters.

Okay Rob, and Piotrz, Thanks.

I think this works if you have a background like sky, or clouds, or just colors in the back.

but if I want to have a “fix” background.

Like the image of a pinball machine, where the edge of the machine is the ending of the background.

and that image will be different for each device.

how do I do that?

do I have to include 5 or 6 different sizes of the same image, and the config.lua will choose the “correct” one?

and also what do you mean by --“give half of dimension when writing width and height parameters.”–

Thanks

If your background has design elements that won’t work if part of the background bleeds off the screen or if certain elements have to be in the right place based on the screen shape, then yes, you have to include multiple backgrounds and use “if” statements to determine which one to load.

I got it, thanks Rob.