Page 1 of 1
(Solved) Figuring out the position with Y and X
Posted: Thu Jul 12, 2012 8:47 pm
by Stepper
I have been struggling with figuring out the position for x and y. And I do not know how to know the exact position of the screen where to put it. I always play around till I have the good positions
Re: Figuring out the position with Y and X
Posted: Thu Jul 12, 2012 9:35 pm
by Santos
Try this, it will tell you what x and y position your mouse is at!
Code: Select all
function love.draw()
-- Put other things here!
love.graphics.print('x: '..love.mouse.getX(), 8, 8)
love.graphics.print('y: '..love.mouse.getY(), 8, 20)
end
Re: Figuring out the position with Y and X
Posted: Thu Jul 12, 2012 9:45 pm
by Stepper
What if I am also coding for other langauges? How do I do that?
THANKS, Also, it works great.
Re: Figuring out the position with Y and X
Posted: Thu Jul 12, 2012 9:52 pm
by Santos
I don't quite understand what you mean sorry. Do you mean how would you find the X and Y positions in other languages? If so, you could:
- Find out how to print text to the screen
- Find out how to get the x and y position of the mouse
- Print the numbers of the x and y position of the mouse to the screen
I think most other languages/frameworks use a similar coordinate system to LÖVE, with the top left corner being (x: 0, y: 0), and the x and y values increasing as you go right and down respectively, so (x: 10, y: 20) would be 10 pixels from the right of the screen, and 20 pixels down.
Sorry if I've misunderstood!

Re: Figuring out the position with Y and X
Posted: Fri Jul 13, 2012 1:28 pm
by Stepper
Tried it, and thanks. I just did it in Java and C++.