How to check if touch press is in a triangle [SOLVED]

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
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

How to check if touch press is in a triangle [SOLVED]

Post by test »

I use love.graphics.polygon to draw triangles. But how can I check if touch press is in a triangle?
Last edited by test on Tue May 07, 2019 7:17 pm, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to check if touch press is in a triangle

Post by zorg »

Simple. You need to detect a collision between a triangle shape and a point. Löve doesn't have a built-in function for that. The internet has tons of examples though, just search it and adapt the code to lua.
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
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: How to check if touch press is in a triangle

Post by ivan »

Point in triangle is a relatively simple check:
https://2dengine.com/?p=intersections#P ... e_triangle
If you want the touch area to be larger (circle) then it's slightly more complicated:
https://2dengine.com/?p=intersections#C ... s_triangle
Post Reply

Who is online

Users browsing this forum: Google [Bot], MrFariator and 168 guests