How to check if touch press is in a triangle [SOLVED]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to check if touch press is in a triangle [SOLVED]
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.
- 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
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 True 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.
Re: How to check if touch press is in a triangle
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
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
Who is online
Users browsing this forum: Google [Bot], MrFariator and 168 guests