Android tilt

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
soytak111
Prole
Posts: 25
Joined: Sat Sep 17, 2022 1:00 am

Android tilt

Post 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?
lua,contrary to other language,give you as much space as moon :awesome:
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: Android tilt

Post 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
soytak111
Prole
Posts: 25
Joined: Sat Sep 17, 2022 1:00 am

Re: Android tilt

Post by soytak111 »

thank you! I thought joystick was to display a joystick
lua,contrary to other language,give you as much space as moon :awesome:
Post Reply

Who is online

Users browsing this forum: Google [Bot], WexDex and 28 guests