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 axis
number direction
function 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