Building Apps for iPhone and iPhone 5 Help

Good tutorial that can help anyone who is very much interested in custom apps development for iPhone. Thanks for sharing the link to the tutorial post. [import]uid: 198035 topic_id: 33970 reply_id: 135091[/import]

Hi, the code I am using to display my background which is the iPhone 5 size (1136x640) is:

local background = display.newImage (“tp.png”)

the config.lua code is:

elseif ( string.sub ( system.getInfo( “model”), 1, 2 ) == “ip” ) then
application =
{
content=
{
width = 640,
height = 960,
scale, = “letterBox”,
xAlign = “center” ,
yAlign = “center” ,
image suffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,

},
},
}

I’m not sure what I’m missing or doing improperly. If anyone can help that would be great. Thanks, Joseph [import]uid: 202772 topic_id: 33970 reply_id: 135116[/import]

@jfaure98, ah, okay, you need to use display.newImageRect for your background:

local background = display.newImageRect (“tp.png”, w, h)

For w & h, you need to specify the width and the height of the image so that the app can pick the properly scaled image (assuming you have included @2x and @4x images.) Take a look at the API page for newImageRect: http://docs.coronalabs.com/api/library/display/newImageRect.html

Naomi

Edit: just noticed you have the w & h, so it would be (assuming you’re doing landscape):
local background = display.newImageRect (“tp.png”, 1136, 640)

Edit2: BTW, you do have Default-568h@2x.png file in your project folder, right? You need it to trigger the iPhone5 display. [import]uid: 67217 topic_id: 33970 reply_id: 135124[/import]

Naomi, i tried it and I think it will work but its zooming in on my background and only showing the lower left corner. What do you think the problem is?
Also, I don’t have the 2x png. How do I go about putting one in my folder? Will there be two of the same image? One regular size and one 2x png? Thank you for your time. Thanks, Joseph [import]uid: 202772 topic_id: 33970 reply_id: 135158[/import]

Hey, @ jfaure98, I don’t think you need 2x file since you are starting off with a big file. (In my case, my base image files are made for 480x320 screen, and I add @2x and @4x to accommodate for greater screen resolution.) I’m not sure what you mean by “zooming in on my background” though. Based on the config you have, I don’t know why it would zoom.

About lower left corner, maybe you are not placing the image on the center of the screen? I always place my display objects in relative to the center of the screen, like so:

local screenW = display.contentWidth  
local screenH = display.contentHeight  
local background = display.newImageRect ("tp.png", 1136, 640)  
background.x = 0.5\*screenW  
background.y = 0.5\*screenH  

I hope this helps.

Naomi
[import]uid: 67217 topic_id: 33970 reply_id: 135163[/import]

Thanks so much, Naomi! I got my background situation squared away just the way I want it. Thanks for all of the help, Joseph [import]uid: 202772 topic_id: 33970 reply_id: 135177[/import]

Glad to hear you got it working, Joseph!

Cheers,
Naomi [import]uid: 67217 topic_id: 33970 reply_id: 135182[/import]

Naomi, one last question. How can I do this to the whole app? I would like to make my menu center in the screen but the iPhone 5 has different Y locations than the 4 (1136 and 960). Thanks, Joseph [import]uid: 202772 topic_id: 33970 reply_id: 135245[/import]

Hey, Joseph, if you use [text]display.contentWidth[/text] and [text]display.contentHeight[/text] as described in post #10 above, you should be able to position any object in the center of the screen regardless of the device resolution. (I position my objects in relative to the center of the screen in my app, and it has served me well.)

Naomi

Edit: by the way, you can insert your display objects into display groups, and then have the display group repositioned in relative to the screen center. If you go that route, you’d want to place your individual objects with 0,0 coordinate as the center. (Hope you get what I mean… if not, the best thing you could do is to experiment and see how it goes.) [import]uid: 67217 topic_id: 33970 reply_id: 135276[/import]