|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
− | '''Tactile''' is a flexible and straightforward input library for LÖVE to help you manage multiple input sources. Have an example!
| |
| | | |
− | <source lang="lua">
| |
− | 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
| |
− | </source>
| |
− |
| |
− | Get the code on [https://github.com/tesselode/tactile GitHub]!
| |