Page 1 of 1

using if statements with mousepressed doesnt work

Posted: Thu Feb 25, 2016 2:26 am
by fixylol
when i use love.mousepressed by itself it works, but when i use an if statement it stops working (and if i use an elseif statement keypressed stops working too :/)

Re: using if statements with mousepressed doesnt work

Posted: Thu Feb 25, 2016 3:13 am
by farzher
cooooooooode

paste code and or a .love file

Re: using if statements with mousepressed doesnt work

Posted: Thu Feb 25, 2016 3:20 pm
by fixylol

Code: Select all

function love.load()
    coolthing = love.graphics.newImage("awesome.jpg")
    love.graphics.setBackgroundColor(255,255,255)
    imgx = 0
    imgy = 0
end

function love.draw()
    love.graphics.draw(coolthing,imgx,imgy)
end

function love.mousepressed(x,y,button,istouch)
    if button == "1" then
        imgx = x
        imgy = y
    end
end

function love.keypressed(key)
    if key == "x" then
        imgx = 10
        imgy = 10
    end
end

Re: using if statements with mousepressed doesnt work

Posted: Thu Feb 25, 2016 4:18 pm
by monolifed
try

Code: Select all

if button == 1 then
button is a number (starting with 0.10.0 https://love2d.org/wiki/love.mousepressed)