Implement joystick, recognize background inputs
This commit is contained in:
parent
768eed8787
commit
0d8bf75228
2 changed files with 54 additions and 40 deletions
13
button.lua
13
button.lua
|
@ -10,10 +10,19 @@ function Button:new(x, y, r, b)
|
|||
end
|
||||
|
||||
function Button:update(dt)
|
||||
if love.keyboard.isDown(self.b) then
|
||||
if self.b == "triggerleft" or self.b == "triggerright" then
|
||||
local axis = joystick:getGamepadAxis(self.b)
|
||||
if axis > 0.5 then
|
||||
self.press = true
|
||||
else
|
||||
else
|
||||
self.press = false
|
||||
end
|
||||
else
|
||||
if joystick:isGamepadDown(self.b) then
|
||||
self.press = true
|
||||
else
|
||||
self.press = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue