Difference between revisions of "tactile"

(Created page with "'''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()...")
 
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!
+
'''Tactile''' is a flexible and straightforward input library for LÖVE to help you manage multiple input sources. Get the code on [https://github.com/tesselode/tactile GitHub].
  
 
<source lang="lua">
 
<source lang="lua">
Line 33: Line 33:
 
end
 
end
 
</source>
 
</source>
 
Get the code on [https://github.com/tesselode/tactile GitHub]!
 

Revision as of 02:37, 20 July 2015

Tactile is a flexible and straightforward input library for LÖVE to help you manage multiple input sources. Get the code on GitHub.

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