offset yAlign for iPhone 5

can anyone tell me if theres an easier way of doing this

I have my app working fine across iPhone 3 & 4, and iPad 1-3

when it comes to the iPhone 5 because of the taller screen all the positioning I have set is out
where I have set an object at y=50 for the olther devices on the iPhone 5 I need it to be y=94 (and offest of 44) so that it matches the postion of the others rather than being to far up the screen

is there any way of doing this in the config file?
or do I have to manually do it to each lua file??

my current config file is checking if the device is an iPhone 5 using

elseif string.sub(system.getInfo("model"),1,2) == "iP" and display.pixelHeight \> 960 then

if I have to do it manually I’ll be adding

elseif string.sub(system.getInfo("model"),1,2) == "iP" and display.pixelHeight \> 960 then iPhone5 = true;

then add this to each lua file

-- Add an extra 44 to the positions if using an iPhone 5  
 local ip5 = 0  
 if iPhone5 == true then  
 ip5 = 44  
 end  

and then finally this to each object

object.y = 420 + ip5  

just wanted to see if there was an easier way of doing this before spending hours making the changes [import]uid: 68633 topic_id: 35235 reply_id: 335235[/import]

Hello,
Is this like some UI element or button that you want to position from a “fixed distance” from an edge of the screen, regardless of device?

There are a few solutions, so this isn’t by any means the “definitive” one… but basically, I use two programmatically-determined “offset” values that give me the pixel distance outside my “content region” on any device. So, if I have a “standard” screen content size (iPhone3 or 4), and I run on iPad (wider), I can get the pixel offset on both left and right (assuming portrait orientation). On iPhone5 or other “tall” devices, I can get the pixel offset on top and bottom. This assumes letterbox scaling setup in the config, centered.

Here’s the code… I put this at the top of my “main.lua” so I can access the vars further down:

local ox, oy = math.abs(display.screenOriginX), math.abs(display.screenOriginY)

Now, if I want to display something left-aligned (flush) on any screen, I just subtract “ox” from its position. Flush right, add “ox”. Top, subtract “oy”, and bottom, add “oy”.

You can try printing those values and seeing the result in the Terminal as you change device views in the Simulator.

Does this help? Again, it’s just one way, and it depends on your config setup and a few other things. But it should save you the need to constantly detect iPhone5 and hard-code that “44” value in, which might change if you adjust your content size, or when new devices come out.

Brent [import]uid: 200026 topic_id: 35235 reply_id: 140088[/import]

Hello,
Is this like some UI element or button that you want to position from a “fixed distance” from an edge of the screen, regardless of device?

There are a few solutions, so this isn’t by any means the “definitive” one… but basically, I use two programmatically-determined “offset” values that give me the pixel distance outside my “content region” on any device. So, if I have a “standard” screen content size (iPhone3 or 4), and I run on iPad (wider), I can get the pixel offset on both left and right (assuming portrait orientation). On iPhone5 or other “tall” devices, I can get the pixel offset on top and bottom. This assumes letterbox scaling setup in the config, centered.

Here’s the code… I put this at the top of my “main.lua” so I can access the vars further down:

local ox, oy = math.abs(display.screenOriginX), math.abs(display.screenOriginY)

Now, if I want to display something left-aligned (flush) on any screen, I just subtract “ox” from its position. Flush right, add “ox”. Top, subtract “oy”, and bottom, add “oy”.

You can try printing those values and seeing the result in the Terminal as you change device views in the Simulator.

Does this help? Again, it’s just one way, and it depends on your config setup and a few other things. But it should save you the need to constantly detect iPhone5 and hard-code that “44” value in, which might change if you adjust your content size, or when new devices come out.

Brent [import]uid: 200026 topic_id: 35235 reply_id: 140088[/import]