Page 1 of 1

love.graphics.scale() and cursor position

Posted: Tue Jan 15, 2013 9:53 pm
by tomshreds
Hi,

I'm trying to use

Code: Select all

love.graphics.scale()
but since I use it mouse position is off. What could I do to use proper mouse positions?

Each time I click, it clicks on the offset position of

Code: Select all

scale()
.

Any ideas of what I should do?

I tried

Code: Select all

TLfres
but it didn't do the trick and does the same problem. (I also posted in that thread).

Thanks and have a nice day!

Re: love.graphics.scale() and cursor position

Posted: Tue Jan 15, 2013 10:35 pm
by micha
You can simply divide the mouse coordinates by the scale factor.
Example: Scaling by factor 3 means that the mouse x-coordinate 150 is the x-coordinate 150/3=50 in your game coordinates.

However this will only work if you do not also use translate. In that case, you'd have to keep track of all transformations.

Re: love.graphics.scale() and cursor position

Posted: Tue Jan 15, 2013 10:37 pm
by tomshreds
micha wrote:You can simply divide the mouse coordinates by the scale factor.
Example: Scaling by factor 3 means that the mouse x-coordinate 150 is the x-coordinate 150/3=50 in your game coordinates.

However this will only work if you do not also use translate. In that case, you'd have to keep track of all transformations.
Ok thanks, I'll try this out!