Available since LÖVE 0.9.0
This function is not supported in earlier versions.
Gets the direction of a virtual gamepad axis. If the Joystick isn't recognized as a gamepad or isn't connected, this function will always return 0.
direction = Joystick:getGamepadAxis( axis )
GamepadAxis axisnumber directionfunction love.load()
x = 0
y = 0
p1joystick = nil
end
function love.joystickadded(joystick)
p1joystick = joystick
end
function love.update(dt)
-- Check if joystick connected
if p1joystick ~= nil then
-- getGamepadAxis returns a value between -1 and 1.
-- It returns 0 when it is at rest
x = x + p1joystick:getGamepadAxis("leftx")
y = y + p1joystick:getGamepadAxis("lefty")
end
end
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/Joystick:getGamepadAxis