Hi, I would like to make apps that run on both the iPhone 4 (and previous) and the iPhone 5 . I would like to make the app in the iphone 5 height. If I did this, how would I get the iPhone 4 to cut off the bottom of the iPhone 5 height app so it fit? I’ve tried this in the simulator but it shrunk the iPhone5 height background so the whole thing fit in the iPhone 4 screen, but I want the bottom not to show so it takes up the whole iphone 4 screen. Thanks, Joseph [import]uid: 202772 topic_id: 33970 reply_id: 333970[/import]
Hey, @jfaure98, you might want to take a look at this blog post. It’s thorough, and if you follow it, you should be able to achieve what you’re trying to do:
http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file
Naomi [import]uid: 67217 topic_id: 33970 reply_id: 135032[/import]
Thanks, Naomi! [import]uid: 202772 topic_id: 33970 reply_id: 135038[/import]
You’re welcome. Good luck!
Naomi [import]uid: 67217 topic_id: 33970 reply_id: 135048[/import]
Hi, I just tried the code. I’m not sure why but it’s not doing anything to my background. I typed exactly what the code said. Am I missing something? If anyone could help that would be great. [import]uid: 202772 topic_id: 33970 reply_id: 135080[/import]
@jfaure98, you might want to post your config.lua file and the code that you use to display your background. Perhaps someone can help trouble shoot your code once you post it. Without any of the details relating to your problem, it would be difficult for anyone to offer any further help – especially since there’s no way to spot what might went wrong with your attempt to follow the tutorial blog without seeing your code.
Naomi
[import]uid: 67217 topic_id: 33970 reply_id: 135082[/import]
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]
Hey, @jfaure98, you might want to take a look at this blog post. It’s thorough, and if you follow it, you should be able to achieve what you’re trying to do:
http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file
Naomi [import]uid: 67217 topic_id: 33970 reply_id: 135032[/import]
Thanks, Naomi! [import]uid: 202772 topic_id: 33970 reply_id: 135038[/import]
You’re welcome. Good luck!
Naomi [import]uid: 67217 topic_id: 33970 reply_id: 135048[/import]
Hi, I just tried the code. I’m not sure why but it’s not doing anything to my background. I typed exactly what the code said. Am I missing something? If anyone could help that would be great. [import]uid: 202772 topic_id: 33970 reply_id: 135080[/import]
@jfaure98, you might want to post your config.lua file and the code that you use to display your background. Perhaps someone can help trouble shoot your code once you post it. Without any of the details relating to your problem, it would be difficult for anyone to offer any further help – especially since there’s no way to spot what might went wrong with your attempt to follow the tutorial blog without seeing your code.
Naomi
[import]uid: 67217 topic_id: 33970 reply_id: 135082[/import]