In my game setup I have a class "Cursor" which derives from "Sprite".
It's a child of a ConvasLayer called "UILayer" which holds UI elements that's should remain static (and can be clicked).
Depending on mouse movement, click, and touch events, the cursor's "Position" is updated. If I print the cursor's position, I can see that 0/0 is always top left of my gaming window and bottom right is 479/269, independent of viewport settings.
My goal is to find out what tile on the TileMap was clicked. I'm using my tilemap's world_to_map() function, however, I cannot get the input coordinates right, because obviously the screen coordinates won't work.
In the example below, the tilemap's 0/0 is where the cursor is pointing to. In the canvas layer's coordinates that's 240/50.
So for the given map, I'd have to subtract 240 on X and 50 on Y to get my coordinates. But other maps may have a different origin.
How can I achieve my goal to convert from screen coordinates to cell position on the tilemap while taking into account the camera position (child of the player character)?
