Page 1 of 1
Using mouse input, left mouse button not doing anything??
Posted: Wed Jun 20, 2018 8:07 am
by PixelPixel
This works nicely for the right mouse button
Code: Select all
if love.mouse.isDown(1) then
text = "Right mouse button has been pressed"
end
Left mouse button however causes troubles, I tried other index numbers too, still nilch, nada & zero reaction from love
here is the code...
Code: Select all
if love.mouse.isDown(2) then
text = "Left mouse button has been pressed"
end
What to do?
Re: Using mouse input, left mouse button not doing anything??
Posted: Wed Jun 20, 2018 8:13 am
by KayleMaster
Where did you put that code? Can you share your project? It should work, but I don't know the context.
EDIT: isn't 1 left mouse button and 2 right mouse button?
Re: Using mouse input, left mouse button not doing anything??
Posted: Wed Jun 20, 2018 8:47 am
by PixelPixel
Sorry for not giving much context or code, I put the code in the update function;
Code: Select all
function love.update(dt)
if love.mouse.isDown(1) then
text = "Right mouse button has been pressed"
end
if love.mouse.isDown(2) then
text = "Left mouse button has been pressed"
end
end
Re: Using mouse input, left mouse button not doing anything??
Posted: Wed Jun 20, 2018 8:51 am
by grump
What do you expect that code to do?
Re: Using mouse input, left mouse button not doing anything??
Posted: Wed Jun 20, 2018 8:54 am
by KayleMaster
I guess he has text in a love.graphics.print in love.draw.
Anyways, you've got them wrong, they're the other way around. 1 is left mouse, 2 is right mouse, 3 is middle mouse button.
Re: Using mouse input, left mouse button not doing anything??
Posted: Wed Jun 20, 2018 9:04 am
by PixelPixel
I've got it working now, here is the full code
I have no idea why it wasn't working properly before but now it is..
Code: Select all
local text
function love.load()
love.graphics.setNewFont(12)
text = "Nothing yet"
end
function love.update(dt)
if love.mouse.isDown( '1' ) then
text = "Left mouse button has been pressed"
end
if love.mouse.isDown( '2' ) then
text = "Right mouse button has been pressed"
end
end
function love.draw()
love.graphics.print( text, 330, 300 )
end