Have an example!
Code: Select all
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.newAxis(keyboardXAxis, gamepadXAxis)
shoot = tactile.newButton(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
This is my first library (that useless highscore table library I made a couple years ago doesn't count), so please let me know anything I could be doing better.