Hi, probably one for Mr Miracle.
I have tried to size and place screen backgrounds according to the general advice to cope with different devices.
The screen size in coronas is 1024x768 (landscape mode only). The images are sized at 1425X900 pixels and centred on screen with overlap around a main image area of 1024/768, with bleeding on main screen decorations to make the space on wide devices look ok. I also create x2 images of 2850*1800.
Both of these look fine, but I have a wee arithmetic problem.
On phone devices the widgets and buttons are very small and difficult to hit. My solution is to have a background touch listener that scales the screen x2 when touched off a widget so that users get a magnified image. I use event.x and event.y to tell where on the screen (1024x768) has been touched. The idea then is that the scaled image’s centre is moved so that the scaled image is shown around the touched point. After a short delay it scales back down.
I found this works:
screenGroup.xScale = 2.0
screenGroup.yScale = 2.0
screenGroup.x = display.screenOriginX/20 - event.x
screenGroup.y = display.screenOriginY/2 - event.y
Works on all devices!!!
My problem is that although the above code works, my arithmetic came up with a completely different set of numbers for screenGroup.x and y
I’d like to get my head around WHY the above code works, even although empirically it does.