Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with mouse position  (Read 988 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
Problem with mouse position
« on: August 26, 2022, 05:19:07 pm »
I have a problem with my cursor position when I use the "sf :: View view" camera control my cursor loses its real position.

when I don't use "view" the cursor matches its coordinates,
but when I create a view, the coordinates are completely different from the cursor. And the view follow the object, and the object follows the cursor and when the cursor coordinates do not match, I have no control over the object.

in the photos I marked the cursor with white.
On the 13th photo I am using view.
At 14h photo, I don't use view
« Last Edit: August 26, 2022, 05:21:24 pm by Tomasz »


  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Problem with mouse position
« Reply #1 on: August 26, 2022, 07:28:17 pm »
Your cursor has a position in pixels, relative to the screen or the window. Entities inside your game have coordinates in "world units".
If you want to convert your mouse position in pixels to its corresponding coordinates in the game world, use the mapPixelsToCoords function