Letterbox scaling maximum x value on other screen widths

I’m stuck again so I need to turn to the Corona gods for some advice!

I’m using letterbox scaling in my config file based on 480 x 320. I place a button at x 480 (with right reference point) on iphone and its right at the edge of the screen in the right place.

How do I make said button go to the equivalent of 1136 pixels when on wider screens? What is the calculation? The value that works in the project is somewhere near 520 px for the iphone 5 and galaxy etc. [import]uid: 148866 topic_id: 34242 reply_id: 334242[/import]

Since you are using a 320x480 setting, the retina iPhones are 640x960 which is the same as 320*2 by 480*2. To get the opposite calculation, starting at 640x960, simply divide by 2 and you’re back to 320x480. For the iPhone 5, which is 640x1136 you end up with 1136 / 2 or 568.

Your right edge on a landscape iPhone 5, is therefore at position 568 but not really. Now given you’re config is only defining 320x480 then 0,0 is NOT going to be the top left corner nor is 480x320 going to be the bottom right corner. That 480x320 area is going to be centered on the screen. You’re left edge is actually going to be at Y = -44 and the right edge is going to be at 480 + 44.

Keep in mind that display.contentWidth is going to be 480 with your config.

Hopefully this will make sense. [import]uid: 199310 topic_id: 34242 reply_id: 136145[/import]

Hi rob this sort of makes sense to me thanks. What would be a safe bit of code to put in to calculate this to work on most of the common sizes? [import]uid: 148866 topic_id: 34242 reply_id: 136165[/import]

Hi @NoobChoobGames,
Did you read Rob’s tutorial about the ultimate config.lua? This should help if you haven’t already read it.

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

Brent [import]uid: 200026 topic_id: 34242 reply_id: 136181[/import]

Thats great thanks Brent :slight_smile: [import]uid: 148866 topic_id: 34242 reply_id: 136195[/import]

Since you are using a 320x480 setting, the retina iPhones are 640x960 which is the same as 320*2 by 480*2. To get the opposite calculation, starting at 640x960, simply divide by 2 and you’re back to 320x480. For the iPhone 5, which is 640x1136 you end up with 1136 / 2 or 568.

Your right edge on a landscape iPhone 5, is therefore at position 568 but not really. Now given you’re config is only defining 320x480 then 0,0 is NOT going to be the top left corner nor is 480x320 going to be the bottom right corner. That 480x320 area is going to be centered on the screen. You’re left edge is actually going to be at Y = -44 and the right edge is going to be at 480 + 44.

Keep in mind that display.contentWidth is going to be 480 with your config.

Hopefully this will make sense. [import]uid: 199310 topic_id: 34242 reply_id: 136145[/import]

Hi rob this sort of makes sense to me thanks. What would be a safe bit of code to put in to calculate this to work on most of the common sizes? [import]uid: 148866 topic_id: 34242 reply_id: 136165[/import]

Hi @NoobChoobGames,
Did you read Rob’s tutorial about the ultimate config.lua? This should help if you haven’t already read it.

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

Brent [import]uid: 200026 topic_id: 34242 reply_id: 136181[/import]

Thats great thanks Brent :slight_smile: [import]uid: 148866 topic_id: 34242 reply_id: 136195[/import]