Resolution independance and placing an image...quick question...

Ok, so I’ve read a lot of beginner tutorials, watched a lot of videos and think I’m now ready to start making the basics of my first app, a simple sound board to learn the basics of Corona with. Which I can then build up into a half decent app.

I’m trying it make it with Resolution Independance and have it working referring to different scaled images fine. I’ve read and watched the provided tutorials on the subject.

I just want to check I’m doing the positioning properly.

To make sure the buttons will be positioned properly on any device, apple phones, ipads, android phones and tabled.

Is it best to do the postioning, using divisions of the display.content width and height as below:

--Below creates an attribute which contains the devices height and the devices width  
local \_H = display.contentHeight;  
local \_W = display.contentWidth;  
-- load in backgorund image, with retina functionality by using display.newImageRect, and is centred  
local background01 = display.newImageRect( "images/background.png", 320, 480)  
background01:setReferencePoint(display.CenterReferencePoint);  
background01.x = \_W/2; background01.y = \_H/2;  
  
local button\_up = display.newImageRect( "images/button\_up.png", 140, 42)  
button\_up:setReferencePoint(display.CenterReferencePoint);  
button\_up.x = \_W/1.3; button\_up.y = \_H/2;  
  

or to use the display width and height + a number of pixels to get the position correct, or will that muck up at times? (please note the numbers I’ve typed in are for example only)

–Below creates an attribute which contains the devices height and the devices width

[code]
local _H = display.contentHeight;
local _W = display.contentWidth;
– load in backgorund image, with retina functionality by using display.newImageRect, and is centred
local background01 = display.newImageRect( “images/background.png”, 320, 480)
background01:setReferencePoint(display.CenterReferencePoint);
background01.x = _W/+25; background01.y = _H/-100;

local button_up = display.newImageRect( “images/button_up.png”, 140, 42)
button_up:setReferencePoint(display.CenterReferencePoint);
button_up.x = _W/+50; button_up.y = _H/-120; [/code]

I hope this all makes sense, its my first proper Corona related question… so please go easy on me… [import]uid: 47346 topic_id: 8819 reply_id: 308819[/import]

I find that for centering objects, dividing screen dimensions in half is sufficient… things could get really strange if you start dividing too many things up to try to get everything perfect on every device.

I find the best way to do things is to divide by 2 if I’m centering, otherwise, I’ll use absolute positioning, a specific amount of pixels away from some kind of reference point (such as a screen border).

If you’re trying to appeal to different devices, most likely you’ll have to provide separate resources (especially for things like background images) and conditionally handle those things anyway.

However, if you can divide things properly to where things are consistent in your app from device-device and it doesn’t actually make the functionality different depending on device, I don’t see a problem with using your method–it’s just about making sure things really are consistent.

The last thing you want is a different experience for the same app on a different device (unless it’s meant to be a different experience–such as an iPhone app vs. an iPad app). [import]uid: 52430 topic_id: 8819 reply_id: 32404[/import]