Page 1 of 1
Mouse position isn't accurate with graphics translation.
Posted: Fri Oct 10, 2014 12:12 am
by Dr.Tyler O.
In the game that I'm making, you right click and a menu pops up right next to the mouse that gives you a list of options for the object you right clicked (similar to something like this:
http://www.zybez.net/img/genimg/getting ... ptions.png). But when I added love.graphics.translate() to make the camera stick to the player, the right click menu gets farther away from the player as the player moves. I don't know a lot about the camera functions in love but I feel like I'm doing it completely wrong. I simply put love.graphics.translate(x, y) in love.draw() and that's it. That also causes text to lag behind the player when the camera moves but that is irrelevant to my current question.
Re: Mouse position isn't accurate with graphics translation.
Posted: Fri Oct 10, 2014 12:50 am
by artofwork
Post the code.... or a love file and we can help you!
That is going to be my signature from now on because I'm kind of tired of typing it in threads that ask a question but never post the code or a love file...
Your code can't be that amazing that someone here is going to steal it... Because if it was you would not be on these forums asking these questions.
Re: Mouse position isn't accurate with graphics translation.
Posted: Fri Oct 10, 2014 1:00 am
by Xrott
Love.graphics.translate doesn't affect the mouse input coordinates. You need to apply the offset to the mouse x and y positions in reverse.
For example, if you translate the x coordinates by 5, you need to subtract 5 from the mouse x.
There is no need to get rude here. Sometimes you can figure stuff out even without the code.
Re: Mouse position isn't accurate with graphics translation.
Posted: Fri Oct 10, 2014 1:15 am
by Dr.Tyler O.
artofwork wrote:Post the code.... or a love file and we can help you!
That is going to be my signature from now on because I'm kind of tired of typing it in threads that ask a question but never post the code or a love file...
Your code can't be that amazing that someone here is going to steal it... Because if it was you would not be on these forums asking these questions.
My question was just answered right after you stated this. In my opinion, most questions don't require a love file unless the problem is really in depth. Thank you for trying to provide help though.
Xrott wrote:if you translate the x coordinates by 5, you need to subtract 5 from the mouse x.
Thanks dude.
Re: Mouse position isn't accurate with graphics translation.
Posted: Fri Oct 10, 2014 10:18 am
by Robin
In this case, Xrott guessed right. Without a .love, that's all we can do: guess.
Please always supply a .love. It is a courtesy to the people helping you as much as it helps yourself (because it's more likely you get the right answer right away).
Re: Mouse position isn't accurate with graphics translation.
Posted: Fri Oct 10, 2014 1:27 pm
by Xrott
No, I didn't guess. I actually read the first post and it was pretty clear what the problem was.
Now, I know you get the situation a lot, where you can't actually help without a .love and I'm not saying that people shouldn't post their code initially, but some of you seem to be a bit prematurely dismissive about topics without .love files.
If you ask me, try to help first, and yell about posting the code later, when that didn't work.