using if statements with mousepressed doesnt work

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
fixylol
Prole
Posts: 21
Joined: Thu Feb 25, 2016 2:16 am

using if statements with mousepressed doesnt work

Post 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 :/)
User avatar
farzher
Prole
Posts: 41
Joined: Fri Jul 31, 2015 5:38 pm

Re: using if statements with mousepressed doesnt work

Post by farzher »

cooooooooode

paste code and or a .love file
butts
fixylol
Prole
Posts: 21
Joined: Thu Feb 25, 2016 2:16 am

Re: using if statements with mousepressed doesnt work

Post 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
monolifed
Party member
Posts: 188
Joined: Sat Feb 06, 2016 9:42 pm

Re: using if statements with mousepressed doesnt work

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

Who is online

Users browsing this forum: Google [Bot] and 81 guests