Hi all,
I am trying to get the physical distance for any screen density device given the content pixels using
event.yStart - event.y
within the ‘touch’ in of the EventListener, such that if i move my finger across a device I want to obtain the physical distance moved using the content pixels of the event that I am working with.
My question is how can I obtain the physical distance?
It was pointed out to me that letterbox should scale everything relative but I wasn’t finding the results to be entirely accurate regarding the physical distance using simply letterbox.
Also I did discover the androiddisplayydpi property i.e. https://docs.coronalabs.com/api/library/system/getInfo.html#androiddisplayydpi which according to the docs says “can be used to can be used to convert pixels to inches and vice versa” sounds like what I need so I tried to apply it:
local dpi = system.getInfo("androidDisplayYDpi") local distanceDpi = (event.yStart - event.y) / dpi
I tested the above with letterbox set in my config.lua but still doesn’t seem to get me the correct physical distance.
I am testing by connecting two devices usb and using adb logcat and printing the distanceDpi value above and there appears a disproportion between the values for each device.
Anyone been able to get good results obtaining physical distance from content pixels from content pixels across all sorts of device? And how so?