The rect is appearing below the top of the screen because not all devices/screens use the same aspect ratio and so they have extra space around the edges.
If your config.lua file states that the game is 640*960 but you are viewing on a device which is “taller” than an iPhone 5 you will have “extra” space at the top and bottom of your screen. So 0, 0 will be slightly lower than the top left.
Similarly if you then ran the same app on an iPad (which is comparatively wider than an iPhone 5) you would have space on the left/right and 0, 0 would be at the top of the screen but slightly away from the left hand edge.
You can do some fancy stuff with your config.lua file to make it fit, or use these values in place of 0 when positioning:
display.screenOriginX, display.screenOriginY
So instead of
local myBox = display.newRect( 10, -34, 20, 20 )
you would do
local myBox = display.newRect( display.screenOriginX + 10, display.screenOriginY - 34, 20, 20 )
Edit: and obviously you can store those variables to something that’s quicker to type:
--main.lua LEFT = display.screenOriginX + 10 TOP = display.screenOriginY --game.lua local myBox = display.newRect( LEFT + 10, TOP - 34, 20, 20 )