I know the wiki says that it does not detect wu and wd and says to use love.mousepressed and love.mousereleased instead.
However, love.mousereleased does not detect the release of the mouse-wheel either. This forces the use of a round-about method:
local wu, wd
function love.load()
wu, wd = false, false
end
function love.draw()
end
function love.update( dt )
-- Use stuff with wu bool.
wu = false
wd = false
end
function love.keypressed( Key )
if Key == 'wu' then wu = true
elseif Key == 'wd' then wd = false end
end
Is this the way to do this, or am I missing something?
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Okay, first of all: you REALLY can't detect mouse release with 'wu' and 'wd' because they're technically not buttons. Just look at it while you're scrolling up or down: there is no "middle-term" or pressed/unpressed terms. There is one thing you can do, though: detect the time passed between each time you "press" it. So you can establish a "maximum" speed for scrolling up/down. Also, it is still a mousepress, and not a keypress. What you did there would never work.
function love.load()
wu, wd = false, false
wuT, wdT = 0, 0
wheelTimer = .25
end
function love.update(dt)
if wuT > 0 then
wuT = wuT - dt
end
if wdT > 0 then
wdT = wdT - dt
end
if wuT <= 0 and wu then
wuT = 0
wu = false
end
if wdT <= 0 and wd then
wdT = 0
wd = false
end
end
function love.mousepressed(x, y, button)
if button == "wu" then
wu = true
wuT = wheelTimer
elseif button == "wd" then
wd = true
wdT = wheelTimer
end
end
You only need to adjust "wheelTimer" to whatever value you prefer
HugoBDesigner wrote:Also, it is still a mousepress, and not a keypress. What you did there would never work.
Oh, my bad. I typed it incorrectly while posting to the forums.
Thanks for the code.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim