going crazy with group positioning problem

Hi All

This is probably my (lack of) understanding as I’m still quite new to Corona but i’m creating a simple app and I’m fighting a problem.

I’m trying to display a background image with a few labels in a group and have it centered on the screen. It seems to work great for (almost) all devices (iPad, iPhone4 and android) but when I view it on the (original) iPhone the content is being shoved to the top of the screen.
The code is below but here is a project file that shows this happening – Just load it up and change skins and you’ll see it centering fine everywhere except for the original iPhone.

I though (think) I was handling this all properly by setting my config.lua to force a 1024x768 virtual screen and it does seem to be (mostly) – I’ve been pulling my hair out trying to sort out what I’m doing wrong (or perhaps it’s a corona bug?)

Thanks

Link to project: http://db.tt/2NDreDR

[lua]-- this seems to work fine on every model except iphone…

– Just put a gray background on the visible area
bg=display.newRect( 0,0,1024,768)
bg:setFillColor(100,100,100)
– Create a group witha background image and two labels
group=display.newGroup()
back=display.newImage( group,“back.png”)
local label = display.newText(group, “top”,200,-50,native.systemFont, 32)
local label2= display.newText(group, “bottom”,200,280,native.systemFont,32)

– scale it to fill the screen
local scale=display.contentScaleX
group:scale(scale,scale)

– position it to the center by setting cetner ref point and then
– setting x & y to center of screen
group:setReferencePoint(display.CenterReferencePoint)
group.y=display.contentHeight/2
group.x=display.contentWidth/2[/lua]
-john
[import]uid: 48162 topic_id: 8470 reply_id: 308470[/import]

I’m running into a similar problem. Something about using the group locations messes things up with the locations of it’s objects. But it seems to work a lot better for me if I set the object’s position to (0,0) before I insert it into a group.

Like this:

[lua]
local label = display.newText( “top”,200,-50,native.systemFont, 32)
label.x, label.y = 0,0
group:insert(label)
group.y=display.contentHeight/2
group.x=display.contentWidth/2[/lua]

I hope that helps. [import]uid: 10211 topic_id: 8470 reply_id: 30538[/import]

Objects within a group will be positioned relative to its group, so if you position a label at the center of the screen and then position the group at 100, 100 then the label will be offset by the same but still at the center of the group.

I find it easier to just position the objects and let the group always stay centered of the screen, I also tend to use CenterReferencePoint at 99% of the time to avoid bugs end errors etc.

Hope it helped.

[import]uid: 13560 topic_id: 8470 reply_id: 30553[/import]

I tried inserting it at 0,0 and then later adjusting it without any success. I’ve become convinced it’s a corona bug but I’m not sure how best to submit it…

[import]uid: 48162 topic_id: 8470 reply_id: 30559[/import]