Fixed fit projection with camera issue html5 vs desktop

Hi,

I’m trying to understand what is not working in my fixed fit projection with a camera on html5.

There is a clear difference in zoom level between desktop and html5.
In particular building for desktop I’m getting the expected result but when working in html5 and changing resolution via Chrome developer tools, or viewing in iOS browser (both Chrome and Safari), the view is not adapting properly and the reported zoom values are off.
Note that in the game.project the html5 viewport mode is set to stretch as this will need to be used on Poki at some point.

I have been using the screen to world example as a starting point located here, with some minor changes.

Attached you can find my modified example (touch to cycle between the different zoom modes). I might be blind but I can’t seem to find where the problem is.

sample-screen-to-world-coordinates-master.zip (91.0 KB)

And as it always happens, right after writing this post I believe I’ve solved it.

local display_width = sys.get_config_int("display.width")
local display_height = sys.get_config_int("display.height")
local window_width,window_height = window.get_size()
local dpi = window.get_display_scale()
local zoom = (math.min(window_width / display_width, window_height / display_height))/dpi
3 Likes

Looks like you came across similar challenges as in this thread:

1 Like