You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However I don't like getting nil back with push:toGame, so I added an alternate calculation. If method is true It should return 0 or the respective max game width/height instead.
Maybe you care to implement it?
function push:toGame(x, y, method)
x, y = x - self._OFFSET.x, y - self._OFFSET.y
local normalX, normalY = x / self._GWIDTH, y / self._GHEIGHT
if method then
-- new version
x = ( (x < 0 and 0 ) or
( (x >= 0 and x <= self._WWIDTH * self._SCALE.x) and normalX * self._WWIDTH ) or
(x >=self._WWIDTH * self._SCALE.x and self._WWIDTH ) )
y = ( (y < 0 and 0 ) or
( (y >= 0 and y <= self._WHEIGHT * self._SCALE.y) and normalY * self._WHEIGHT ) or
(y >=self._WHEIGHT * self._SCALE.y and self._WHEIGHT ) )
else
-- old code
x = (x >= 0 and x <= self._WWIDTH * self._SCALE.x) and normalX * self._WWIDTH or nil
y = (y >= 0 and y <= self._WHEIGHT * self._SCALE.y) and normalY * self._WHEIGHT or nil
end
return x, y
end
The text was updated successfully, but these errors were encountered:
Hello @GrunHausler, thanks for opening an issue!
I really appreciate the kind words and the effort you made to try to improve the library! push:toGame returning nil values is a design choice, though, that allows the user to know when the mouse is out of the screen. Returning 0 in such cases would be misleading in my opinion, but I am glad you've found a workaround for your own use case.
Thank you for using push, I'm going to close the issue now but I absolutely encourage you to keep contributing and open a pull request next time, whenever you feel like it!
Cheers :-)
Thank you for the code, it really saved time!
However I don't like getting
nil
back withpush:toGame
, so I added an alternate calculation. Ifmethod
is true It should return 0 or the respective max game width/height instead.Maybe you care to implement it?
The text was updated successfully, but these errors were encountered: