Get the immediate mouse position

I’m trying to implement mouse aiming in my game but I can’t get rid of the lag. This video should illustrate what I mean: https://www.youtube.com/watch?v=dJ3ba9l8ns4

I’ve tried to get mouse position on ENTER_FRAME, EXIT_FRAME events from the MouseEvent instance (event.localX/event.localY), also I’ve tried to use mouseX/mouseY properties instead but result is the same…

I feel that I’m missing something.

Have you also tried standard MOUSE_MOVE events?

Is this Linux desktop? What Lime and OpenFL version? Can you test another target (like HTML5) to see if it does the same?

Thanks :slight_smile:

Yep. Arch Linux with i3wm and compton as a compositor if any of that matters :smiley:

Lime - 4.1.0
OpenFL - 5.0.0

So I tried html5 build. It feels like better but still has some notible lag: https://www.youtube.com/watch?v=BJf16uMORho (looks like I recorded 30fps instead of 60 but I hope it’s still visible…)

I used MOUSE_MOVE this time.

Actually it looks like it gets the position which was exactly one frame before… hm…

What are you using to render? Is it the display list sprite.graphics, BitmapData?

I think that you can not get rid of the lag (at least one frame lag will always be).
But you can hide hardware mouse cursor, and draw sprite at mouse coordinates.

I tested a recent and a very old version of OpenFL. Both produced about one frame of lag (I suspect it was exactly one frame, but I’m not sure). Both of these were C++ builds for Linux.

The display list, just one sprite on another.

Well, I think I can live with this 1 frame lag especially with hidden system cursor…