Difference between revisions of "Tactile"
Line 2: | Line 2: | ||
<source lang="lua"> | <source lang="lua"> | ||
− | + | Control = { | |
− | + | Horizontal = tactile.newControl() | |
− | + | :addAxis(tactile.gamepadAxis(1, 'leftx')) | |
− | + | :addButtonPair(tactile.keys 'left', tactile.keys 'right'), | |
− | + | Fire = tactile.newControl() | |
− | + | :addButton(tactile.gamepadButtons(1, 'a')) | |
− | + | :addButton(tactile.keys 'x') | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function love.update(dt) | function love.update(dt) | ||
− | + | Control.Horizontal:update() | |
− | + | Control.Fire:update() | |
− | |||
− | |||
− | |||
− | + | player.x = player.x + player.speed * Control.Horizontal() * dt | |
− | if | + | if Control.Fire:isDown() then |
player:shoot() | player:shoot() | ||
end | end | ||
Line 35: | Line 23: | ||
[[Category:Libraries]] | [[Category:Libraries]] | ||
− | {{#set:LOVE Version=0. | + | {{#set:LOVE Version=0.10.x}} |
{{#set:Description=A flexible and nice input library.}} | {{#set:Description=A flexible and nice input library.}} |
Revision as of 00:04, 13 June 2016
Tactile is a flexible and straightforward input library for LÖVE to help you manage multiple input sources. Get the code on GitHub.
Control = {
Horizontal = tactile.newControl()
:addAxis(tactile.gamepadAxis(1, 'leftx'))
:addButtonPair(tactile.keys 'left', tactile.keys 'right'),
Fire = tactile.newControl()
:addButton(tactile.gamepadButtons(1, 'a'))
:addButton(tactile.keys 'x')
}
function love.update(dt)
Control.Horizontal:update()
Control.Fire:update()
player.x = player.x + player.speed * Control.Horizontal() * dt
if Control.Fire:isDown() then
player:shoot()
end
end