How to work with touch-screens?

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
Tearzz
Prole
Posts: 2
Joined: Sat Jan 27, 2018 8:04 pm

How to work with touch-screens?

Post 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?
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to work with touch-screens?

Post 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
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: How to work with touch-screens?

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests