Page 1 of 1

Possilbe to have love.mousemoved every update?

Posted: Sun Oct 28, 2018 3:19 pm
by fakedeltatime
I'm using the love.mousemoved function to get the Delta movement of the mouse to create some accelerated movement of an object, but the problem I have with it is that it doesn't update when there is no movement. I can fix this by setting the Delta values to 0 at the end of the update loop, but this makes debugging using these values difficult, as the only reading I get is 0. Is there a way to have love.mousemoved update even when there is no movement, or should I just create my own system for it?

Re: Possilbe to have love.mousemoved every update?

Posted: Sun Oct 28, 2018 6:30 pm
by pgimeno
Hi fakedeltatime, welcome to the forums.

No, the whole point of callbacks is to notify you of a change. I'm not aware of any method to cause the event to trigger when there's no change.

I'm not sure how you get the values while debugging, but how about setting them to zero at the end of love.draw instead?

Alternatively, you could patch love.event.pump and reset them there.

If neither of these is acceptable, yes, you'll have to work out your own system by using two variables for the old values and reading love.mouse.getPosition() to calculate the deltas inside love.update().

Re: Possilbe to have love.mousemoved every update?

Posted: Sun Oct 28, 2018 7:40 pm
by grump
Use love.update and query the mouse position with love.mouse.getX() and love.mouse.getY()

Re: Possilbe to have love.mousemoved every update?

Posted: Mon Oct 29, 2018 12:06 am
by zorg
grump wrote: Sun Oct 28, 2018 7:40 pm Use love.update and query the mouse position with love.mouse.getX() and love.mouse.getY()
Or love.mouse.getPosition() as pgimeno said above, which returns both coordinates.