I think you want the layer cssPxToLayer method. There's sample code in the Input event position example.
Your original code sample includes nonexistent methods. There is no such layout method named _canvasToLayer, nor is runtime.input._setMousePosition a valid method. If you used AI to generate it then it's probably just made all that up and given you broken code, which is a pretty typical result unfortunately.
Consider using TypeScript which will show an error if you get something like a method name wrong, and autocomplete will list all the available methods. Here's the TypeScript version of the input event position example.
Hi,
I need a fullscreen stretch mode in Construct 3 - I want the game to stretch to fill the entire browser window (100vw x 100vh) without maintaining aspect ratio, even if it distorts the game slightly.
I tried using CSS to stretch the canvas:
javascriptcanvas.style.width = "100vw";
canvas.style.height = "100vh";
This stretches perfectly, but mouse/touch input coordinates don't work correctly - clicks don't register in the right positions.
You mentioned using layer.cssPxToLayer() - but I don't understand how to use it to fix the input coordinates when the canvas is CSS-stretched.
What I need:
Canvas stretched to full browser viewport (no black bars, no letterbox)
Mouse clicks working in the correct positions
Is there a built-in fullscreen mode for this, or what's the correct way to implement stretch mode with working input?
Thanks!