Page 1 of 1

Stalker-x with translate and scale mouse help

Posted: Mon Feb 19, 2018 10:40 am
by yetneverdone
I need help,
im using stalker-x camera lib, im also using translate and scale as follows:

Code: Select all

function love.draw()
  lg.push()
  lg.scale(game_ratio)
  lg.translate(windowWidth/2/game_ratio-gameWidth/2, windowHeight/2/game_ratio-gameHeight/2) --this draws the game in the center of the window
  Camera: attach ()
  --other draw stuffs
  Camera:detach()
  lg.pop()
end
Before that, i have a clickEntity function, which checks if i clicked on an entity, but now after using camera and translate and scale, i cant get the proper coordinates for checking

Re: Stalker-x with translate and scale mouse help

Posted: Mon Feb 19, 2018 1:59 pm
by Nikki
I am no familiar with stalker-x perse, but it sounds like you need to get the world coords given your mousecoords.
https://github.com/SSYGEN/STALKER-X#toworldcoordsx-y

Re: Stalker-x with translate and scale mouse help

Posted: Mon Feb 19, 2018 2:06 pm
by yetneverdone
Nikki wrote: Mon Feb 19, 2018 1:59 pm I am no familiar with stalker-x perse, but it sounds like you need to get the world coords given your mousecoords.
https://github.com/SSYGEN/STALKER-X#toworldcoordsx-y
Ive tried that, not working as well. The position is kinda off, like it's working when i click a few pixels above the entity itself

Re: Stalker-x with translate and scale mouse help

Posted: Thu Feb 22, 2018 8:02 am
by lachlaan
Try derpy debugging like i do. Print stuff out like the position of your entity and the position of your cursor. Check if the scaling doesn't mess with the actual resolution the game is processed in vs the cursor.

Re: Stalker-x with translate and scale mouse help

Posted: Fri Feb 23, 2018 8:52 am
by hasen
Use the getMousePosition() function from the Stalker-X library.