How to get double-tap
- Gunroar:Cannon()
- Party member
- Posts: 1091
- Joined: Thu Dec 10, 2020 1:57 am
How to get double-tap
Just wondering how one would go about getting a double tap (with keys), instead of it registering as a single tap?
Re: How to get double-tap
If you're talking keyboard, I believe you have to manually check for that. Here's one way:
Use love.keypressed to register key presses in a table, and also store a timer in it. When a key is pressed, check the timer. If it's a short enough time span, call your "double tap" function. Otherwise, update the key's timer in the table, and optionally call your single-press function (or wait until the timer expires, then decided if it's single or double).
Use love.keypressed to register key presses in a table, and also store a timer in it. When a key is pressed, check the timer. If it's a short enough time span, call your "double tap" function. Otherwise, update the key's timer in the table, and optionally call your single-press function (or wait until the timer expires, then decided if it's single or double).
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Re: How to get double-tap
For mouse:
Code: Select all
function love.draw()
love.graphics.print (tostring(mousepressed_presses), 0, 40)
love.graphics.print (tostring(mousereleased_presses), 0, 80)
end
function love.mousepressed( x, y, button, istouch, presses )
mousepressed_presses = presses
end
function love.mousereleased( x, y, button, istouch, presses )
mousereleased_presses = presses
end
Who is online
Users browsing this forum: Bing [Bot], pgimeno and 6 guests