Page 1 of 1

[SOLVED] How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

Posted: Sat Nov 09, 2019 3:34 pm
by ilovelove2019
Hello everyone! I am using the stalker-x camera library to track my characters (I like this library because it has so many character tracking features available). And I have a problem with my mouse, when I use the camera, the shot of the player is no longer accurate (probably because the coordinates of the mouse was wrong). When I disabled the camera everything went back to normal but no one was able to observe my character, the map would be very large later so I needed the camera. I think the problem is that the camera and mouse coordinates are not compatible. To find out more, take a look at my file:

To observe this error, you disable and activate statements 148, 178 and 179 in main.lua at the same time and compare the results. Note, at main.lua 48, 49. I wanted it to be in platform mode but when it crashed I tried to try the screen to screen mode, but not much better. With scr-to-scr, everything seems to be fine at first, but actually when you move the player to the next screen, the error is very obvious. And also note that the shot of the player is starting at row 122 in main.lua.

The main problem is that the player's firing is no longer correct when the camera is turned on. I think I need to do something in the function in row 122. But I'm stupid and incompetent. Please help me.

That is all I have, there are many things still not achieved, I do not want to fail here, please help me and find the answer as soon as possible. I thank you very much and apologize for disturbing your valuable time.

Re: How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

Posted: Sat Nov 09, 2019 6:00 pm
by pgimeno
Every good camera library has functions to convert from screen to world and vice versa. Try this: https://github.com/adnzzzzZ/STALKER-X#u ... dcoordsx-y

If you still have problems after trying that, I'll take a look.

Re: How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

Posted: Sat Nov 09, 2019 11:21 pm
by ilovelove2019
Thank you so much!!! :) It work very well, thank you.