Making an app for both iPhone 4 and iPhone 5

I’d like to be able to run my same app with different graphics on an iPhone 4 vs an iPhone 5.

What’s the best way to set the config.lua to:

width = 640, height = 960 on an iPhone4

and

width - 640, height = 1136 on iPhone5

And then in main.lua to differentiate:

local menuScreen = display.newImage(“StartScreen.jpg”,320,480)    – on iPhone4

local menuScreen = display.newImage(“StartScreen5.jpg”,320,568)    – on iPhone5

Any ideas?

Thanks in advance!

I use this to get the actual device screen size:

local pWidth, pHeight = display.actualContentWidth, display.actualContentHeight

And use the config.lua to determine whether your content is placed centrally or at the top. If you’re targeting all 5 and 4 models I’d say base your display at the top and extend content down if the pHeight is 1136.

Thanks… I did get this working so a single build works the way I wanted on both iPhone 4 and iPhone 5 screens!

display.pixelHeight turned out to be much more reliable than actualContentHeight in my testing

In config.lua, I added the following BEFORE the information in application = {

local pWidth, pHeight = display.pixelWidth, display.pixelHeight local useHeight = 1136 print("Height: ".. pHeight) print("Width: ".. pWidth) if (pHeight \< 1000) then &nbsp;&nbsp;&nbsp;&nbsp;print("iphone 4") &nbsp;&nbsp;&nbsp;&nbsp;useHeight = 960 else &nbsp;&nbsp;&nbsp;&nbsp;print("iphone 5") end

And in the application = {  content = {

width = 640, height = useHeight,

Then in main.lua when I wanted to use different graphics assets based on screen size:

local startScreen if (display.pixelHeight \< 1000) then &nbsp; &nbsp;startScreen = display.newImage("StartScreen.jpg",320,480) else &nbsp;&nbsp; startScreen = display.newImage("StartScreen5.jpg",320,568) end

Hope that is helpful to anyone looking for this informatoin! I did lots of searching to try and find out how to support both screen sizes in a single build in Corona. Using this method, you could position text/buttons/tableviews/anything you need separately for each device size.

I use this to get the actual device screen size:

local pWidth, pHeight = display.actualContentWidth, display.actualContentHeight

And use the config.lua to determine whether your content is placed centrally or at the top. If you’re targeting all 5 and 4 models I’d say base your display at the top and extend content down if the pHeight is 1136.

Thanks… I did get this working so a single build works the way I wanted on both iPhone 4 and iPhone 5 screens!

display.pixelHeight turned out to be much more reliable than actualContentHeight in my testing

In config.lua, I added the following BEFORE the information in application = {

local pWidth, pHeight = display.pixelWidth, display.pixelHeight local useHeight = 1136 print("Height: ".. pHeight) print("Width: ".. pWidth) if (pHeight \< 1000) then &nbsp;&nbsp;&nbsp;&nbsp;print("iphone 4") &nbsp;&nbsp;&nbsp;&nbsp;useHeight = 960 else &nbsp;&nbsp;&nbsp;&nbsp;print("iphone 5") end

And in the application = {  content = {

width = 640, height = useHeight,

Then in main.lua when I wanted to use different graphics assets based on screen size:

local startScreen if (display.pixelHeight \< 1000) then &nbsp; &nbsp;startScreen = display.newImage("StartScreen.jpg",320,480) else &nbsp;&nbsp; startScreen = display.newImage("StartScreen5.jpg",320,568) end

Hope that is helpful to anyone looking for this informatoin! I did lots of searching to try and find out how to support both screen sizes in a single build in Corona. Using this method, you could position text/buttons/tableviews/anything you need separately for each device size.

can you explain that a little differently I don’t understand

can you explain that a little differently I don’t understand