love.wheelmoved (Italiano)
Available since LÖVE 0.10.0 |
This function is not supported in earlier versions. |
Funzione callback chiamata quando si agisce sulla rotella di scroll.
Contents
Funzione
Sintesi
love.wheelmoved( x, y )
Parametri
number (Italiano) x
- Quantità di scroll in orizzontale. Valori positivi indicano scroll verso destra.
number (Italiano) y
- Quantità di scroll in verticale. Valori positivi indicano scroll verso l'alto.
Cosa ritorna
Nulla.
Esempi
local text = ""
function love.wheelmoved(x, y)
if y > 0 then
text = "Hai scrollato in su"
elseif y < 0 then
text = "Hai scrollato in giù"
end
end
function love.draw()
love.graphics.print(text, 10, 10)
end
Scroll graduale
function love.load()
posx, posy = love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5
velx, vely = 0, 0 -- Velocità di scroll
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
-- Riduci gradualmente la velocità per creare uno scroll graduale e non scattoso.
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
Vedi anche
In altre lingue
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info