tactile
Tactile is a flexible and straightforward input library for LÖVE to help you manage multiple input sources. Have an example!
function love.load()
tactile = require 'tactile'
--button detectors
keyboardLeft = tactile.key('left')
keyboardRight = tactile.key('right')
keyboardX = tactile.key('x')
gamepadA = tactile.gamepadButton('a', 1) --the second argument is controller number, in case you're wondering
--axis detectors
keyboardXAxis = tactile.binaryAxis(keyboardLeft, keyboardRight)
gamepadXAxis = tactile.analogStick('leftx', 1)
--controls
horizontal = tactile.addAxis(keyboardXAxis, gamepadXAxis)
shoot = tactile.addButton(keyboardX, gamepadA)
end
function love.update(dt)
--you have to update buttons, sorry for the extra step :(
shoot:update()
--movement
player.x = player.x + player.speed * horizontal:getValue() * dt
--shooting
if shoot:pressed() then
player:shoot()
end
end
Get the code on GitHub!