Need a bit of help with love.touch

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
User avatar
meganukebmp
Prole
Posts: 8
Joined: Thu Jan 07, 2016 10:38 pm
Location: Sofia, Bulgaria

Need a bit of help with love.touch

Post by meganukebmp »

I am adding mobile support to a game I am making. I can't figure out how exactly love.touch and ID's work.
On PC I have it so that when right is pressed, character moves right and when left is pressed, character moves left.
I would like to recreate this with touch events, when left side and right side of the screen are touched. So touch regions? Is that possible?
Also is touch emulation possible on PC with the mouse.
Git of the project https://github.com/meganukebmp/At-the-speed-of-light
.love below
Attachments
ATSOL.love
My code
(5.53 KiB) Downloaded 83 times
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Need a bit of help with love.touch

Post by zorg »

It works similarly to the keyboard and mouse stuff actually;
you can either use the touchpressed/released/moved callbacks, or [wiki]love.touch.getPosition[/wiki] with [wiki]love.touch.getTouches[/wiki] in love.update.
As for regions, just test whether the touch's coordinates are, in case of left/right division only, smaller or bigger than half the width of the screen in pixels, and act accordingly.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Need a bit of help with love.touch

Post by pgimeno »

In 0.10.x you have a parameter 'istouch' in love.mousepressed.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests