love.wheelmoved
Доступно начиная с LÖVE 0.10.0
Эта функция не поддерживается в более ранних версиях.
Функция обратного вызова, вызываемая при перемещении колеса мыши.
Функция
Синопсис
love.wheelmoved( x, y )
Аргументы
number x- Величина горизонтального перемещения колеса мыши. Положительные значения указывают на движение вправо.
number y- Величина вертикального перемещения колеса мыши. Положительные значения указывают на движение вверх.
Возвращаемое значение
Ничего.
Примеры
local text = ""
function love.wheelmoved(x, y)
if y > 0 then
text = "Mouse wheel moved up"
elseif y < 0 then
text = "Mouse wheel moved down"
end
end
function love.draw()
love.graphics.print(text, 10, 10)
end
Плавное прокручивание
function love.load()
posx, posy = love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5
velx, vely = 0, 0 -- The scroll velocity
end
function love.draw()
love.graphics.rectangle( 'line', posx, posy, 50, 50 )
end
function love.update( dt )
posx = posx + velx * dt
posy = posy + vely * dt
-- Gradually reduce the velocity to create smooth scrolling effect.
velx = velx - velx * math.min( dt * 10, 1 )
vely = vely - vely * math.min( dt * 10, 1 )
end
function love.wheelmoved( dx, dy )
velx = velx + dx * 20
vely = vely + dy * 20
end
См. также
© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.wheelmoved