Hello boys and girls!
This is a pretty small question but it has been scratching my brain for far too long.
I want to print the X and Y position of the mouse on the Löve/lua screen, I have been lurking around on the wiki and reading love.mouse functions and love.print but none of them helps me understand properly.
I have done this before but for various reasons I haven't touched lua for a while and I need some help to get the wheels rolling.
Thank you for using your time and helping me!
[SOLVED]Need help: I want to print x and y position of mouse
[SOLVED]Need help: I want to print x and y position of mouse
Last edited by nice on Thu Sep 04, 2014 4:54 pm, edited 1 time in total.
Have a good day!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Need help: I want to print x and y position of mouse
The relevant functions are [wiki]love.mouse.getPosition[/wiki] and [wiki]love.graphics.print[/wiki]. What do you have so far?
Help us help you: attach a .love.
Re: Need help: I want to print x and y position of mouse
I have function love.mouse() set up and I'm looking at the love.mouse.getPosition but even then I don't really understand, I know that you need love.print in here but again I still don't understand where I should where mouse.getPosition should be in there..
Have a good day!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Need help: I want to print x and y position of mouse
Please upload a .love, as per the rules, because it's not clear what you have right now.
Also, love.mouse is not a function or a callback. It is a module. If you override it with a function, it's not going to work.
Also, love.mouse is not a function or a callback. It is a module. If you override it with a function, it's not going to work.
Help us help you: attach a .love.
Re: Need help: I want to print x and y position of mouse
Sorry about that, I'm not very used to the forum thing..
And as requested here's my main.lua file
And as requested here's my main.lua file
- Attachments
-
- main.lua.zip
- (377 Bytes) Downloaded 42 times
Have a good day!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Need help: I want to print x and y position of mouse
Right. That's not a .love, but close enough.
Add
to the top of love.draw().
The first line gets the position of the mouse. The second and third line print the position to the screen.
Also, remove this:
Once again, love.mouse is a module, not a callback function like love.draw!
Add
Code: Select all
local x, y = love.mouse.getPosition()
love.graphics.print("mouse x is: " .. x, 10, 10)
love.graphics.print("mouse y is: " .. y, 10, 40)
The first line gets the position of the mouse. The second and third line print the position to the screen.
Also, remove this:
Code: Select all
function love.mouse()
end
Help us help you: attach a .love.
Re: Need help: I want to print x and y position of mouse
Thank you so much for your help, I really needed it!
I will remember this till next time.
I will remember this till next time.
Have a good day!
Who is online
Users browsing this forum: No registered users and 4 guests