Page 1 of 1

How to work with touch-screens?

Posted: Sat Jan 27, 2018 8:08 pm
by Tearzz
I've been having an idea for an Android game and I've really started to like LÖVE.

Can anyone explain to me in-depth what functions to use and stuff when a touch screen (Android) is tapped on?

Currently I have it like:

Code: Select all

if love.mousepressed then
	-- do something
end
But that doesn't work. I'm not quite sure how to use the love.touch, so if anyone could help me I would be very happy! :awesome:
And can someone explain how to do it for a certain part of the screen and how to do it on the whole screen?

Re: How to work with touch-screens?

Posted: Sat Jan 27, 2018 8:59 pm
by pgimeno
love.mousepressed is a callback, meaning you define it, so that when the mouse is pressed, your function is called and you can act upon it within that function. love.touch is a module; the callback is actually called love.touchpressed. There are more callbacks related to touch; see http://love2d.org/wiki/love#General

Re: How to work with touch-screens?

Posted: Sat Jan 27, 2018 10:05 pm
by ivan
It can be a little confusing since mousepressed, mousereleased, etc report the last touch input as well.
This ensures that PC games will work on Android even if they weren't explicitly programmed for multi-touch.
Many genres of games can work perfectly fine without multi-touch input.