Mouse position isn't accurate with graphics translation.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Dr.Tyler O.
Citizen
Posts: 58
Joined: Tue Jul 29, 2014 9:17 am
Location: United States

Mouse position isn't accurate with graphics translation.

Post 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.
Any topic I have ever posted that I felt did not require a .love file, although they were requested, never required one so I would appreciate if you did not ask me to supply one unless you think that I am ignorant for not doing so.
User avatar
artofwork
Citizen
Posts: 91
Joined: Mon Sep 15, 2014 1:17 am
Location: East Coast USA

Re: Mouse position isn't accurate with graphics translation.

Post 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.
User avatar
Xrott
Prole
Posts: 16
Joined: Thu Aug 15, 2013 1:28 pm
Location: Augsburg

Re: Mouse position isn't accurate with graphics translation.

Post 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.
User avatar
Dr.Tyler O.
Citizen
Posts: 58
Joined: Tue Jul 29, 2014 9:17 am
Location: United States

Re: Mouse position isn't accurate with graphics translation.

Post 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.
Any topic I have ever posted that I felt did not require a .love file, although they were requested, never required one so I would appreciate if you did not ask me to supply one unless you think that I am ignorant for not doing so.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Mouse position isn't accurate with graphics translation.

Post 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).
Help us help you: attach a .love.
User avatar
Xrott
Prole
Posts: 16
Joined: Thu Aug 15, 2013 1:28 pm
Location: Augsburg

Re: Mouse position isn't accurate with graphics translation.

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests