Page 1 of 1

Android tilt

Posted: Mon Mar 13, 2023 11:02 pm
by soytak111
I see some games on android using tilt control like DUAL https://play.google.com/store/apps/deta ... n_US&pli=1 but I don't see anything in love2D to do that, would it still be possible?

Re: Android tilt

Posted: Tue Mar 14, 2023 7:54 am
by Andlac028
I think, you are looking at accelerometerjoystick config option, that (when enabled) adds a "new" joystick that has 3 axes, so you can then use this to get tilt of phone:

Code: Select all

local joystick

function love.load()
    joystick = love.joystick.getJoysticks()[1] -- note, that you may like to get all joystick and select the best one, this just gets the first one
end

function love.update(dt)
    local x, y, z = joystick:getAxes() -- now you can get orientation of phone and process it
end

Re: Android tilt

Posted: Tue Mar 14, 2023 8:10 pm
by soytak111
thank you! I thought joystick was to display a joystick