Mouse problems

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
Wittloc
Prole
Posts: 3
Joined: Fri Nov 21, 2014 5:41 am

Mouse problems

Post by Wittloc »

This function here;

Code: Select all

function love.update(dt)
	if love.mouse.getY() >= 65 and love.mouse.getY() <= 65 + 33 then
		selectedbutton = 1
		if love.mouse.isDown("l") and mon == true then
			mon = false
			gameplay = 2
			wait(2)
			gameplay = 1
		end
	end
end
Doesn't do anything.
mon is a value set to True somewhere else in the script.
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: Mouse problems

Post by szensk »

What does wait(2) do? I suspect it does something that it shouldn't (like sleep for 2 seconds?).

It works perfectly fine in my test. Wait is called once and only once if you click within a y range of 65 to 98.

Code: Select all

local mon = true
local selectedbutton = nil
local gameplay = 0

local function wait(n)
    love.window.setTitle(tostring(love.timer.getTime()))
end

function love.draw()
    local r,g,b,a = love.graphics.getColor()
    local newa = mon and 170 or 255
    love.graphics.setColor(218, 0, 0, newa)
    love.graphics.print(("x: %.2f y: %.2f Gameplay: %d"):format(love.mouse.getX(),
                        love.mouse.getY(), gameplay), 2, 2)
    love.graphics.rectangle("fill", 0, 65, 800, 33)
    love.graphics.setColor(r,g,b,a)
end

function love.update(dt)
    if love.mouse.getY() >= 65 and love.mouse.getY() <= 65 + 33 then
        selectedbutton = 1
        if love.mouse.isDown("l") and mon == true then
            mon = false
            gameplay = 2
            wait(2)
            gameplay = 1
        end
    end
end
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests