X and Y value = 0 but image doesn't spawn at correct place

Hi guys,

I’ve just finished my first game and started testing on physical devices but something weird is going on. I’ve some code to display an image in the top left of my screen but it doesn’t work on all the devices. The values are set to 0 so that should be the same on all devices right? Yet, something it is not displaying at the right place on all the devices. This is the code in question:

 local leftBorder = display.newImage("Img/envr/leftBorder.png") leftBorder.anchorX = 0 leftBorder.anchorY = 0 leftBorder.x = 0 leftBorder.y = 0 sceneGroup:insert(leftBorder)

This is my first real game made with corona sdk so I’ve practically no experience with deploying for multiple devices. But this should work no?

Kind regards

Bram

i’d guess that you’re using letterbox scaling and are seeing this problem on wider devices, where letterbox bars will be present if device aspect ratio ~= content aspect ratio.  if so the fix is to use display.screenOriginX/Y instead of assuming that 0,0 is always top left

Hi, that worked like a charm. Is there also a way to get the value of the end of the screen? I’ve used display.actualContentWidth, but that is also not working.

-- fe: local screenRight = display.screenOriginX + display.actualContentWidth local screenBottom = display.screenOriginY + display.actualContentHeight -- there are other equivalent calculations using .viewableContentWidth/Height -- but .actualContentWidth/Height are more straightforward w letterbox scaling -- (the .viewable\* ones are better w zoomEven scaling)

i’d guess that you’re using letterbox scaling and are seeing this problem on wider devices, where letterbox bars will be present if device aspect ratio ~= content aspect ratio.  if so the fix is to use display.screenOriginX/Y instead of assuming that 0,0 is always top left

Hi, that worked like a charm. Is there also a way to get the value of the end of the screen? I’ve used display.actualContentWidth, but that is also not working.

-- fe: local screenRight = display.screenOriginX + display.actualContentWidth local screenBottom = display.screenOriginY + display.actualContentHeight -- there are other equivalent calculations using .viewableContentWidth/Height -- but .actualContentWidth/Height are more straightforward w letterbox scaling -- (the .viewable\* ones are better w zoomEven scaling)