Help! Objects Being Wrongly Placed

I’ve been trying to make 4 buttons (top, right, bottom and right) that occupy the entire screen without overlapping. I changed reference points for each of them so it’d be easier to position them appropriately:

[lua]btnUp:setReferencePoint(display.TopCenterReferencePoint)

btnRight:setReferencePoint(display.CenterRightReferencePoint)

btnDown:setReferencePoint(display.BottomCenterReferencePoint)

btnLeft:setReferencePoint(display.CenterLeftReferencePoint)

[/lua]

I made it so that their size would match the result I needed. (I’m using a 320x480 screen size)

[lua]btnRight.width = centerX / 2    – CenterX is just H / 2

btnRight.height = H

btnLeft.width = centerX / 2

btnLeft.height = H

btnUp.width =  centerX

btnUp.height = centerY

    

btnDown.width = centerX

btnDown.height = centerY

[/lua]

And the coordinates:

[lua]setPos(btnUp, centerX, 0)     – setPos is just a simple function to set the size   setPos(obj, x, y)

setPos(btnRight, 0, centerY)

setPos(btnDown, centerX, H)

setPos(btnLeft, W, centerY)[/lua]

Bit this is the result I get:

sOLcJ08.png

I’m guessing the sizes don’t match, but I calculated them, so what am I doing wrong?

I think we need to see your setPos function

function setPos(obj, x, y)

 obj.x = x

 obj.y = y

end

function setPos(obj, x, y)

 obj.x = x

 obj.y = y

return

end

I think we need to see your setPos function

function setPos(obj, x, y)

 obj.x = x

 obj.y = y

end

function setPos(obj, x, y)

 obj.x = x

 obj.y = y

return

end