Spiral touch recognazation

Spiral touch recognazation
0

#1

Hi,
I’m trying to recognize a form like in the image. it’s like spiral. Not need to be exactly this form, a six will be valid for example. the form can be done from the center to outside or outside to center.

I stored all points in array, so i can know what is the path that user have done.

Any help? Have a nice day.

#2

try pointInPolygon https://docs.cocos.com/creator/api/zh/classes/Intersection.html#pointinpolygon
get the touch location and transform it to the same space as the polygon, then check if the touch location is inside the polygon
you can manually create an array of points instead of using polygonCollider

#3

You mean i should mock the polygon firstly and then see if the touch points are inside of this polygon with pointInPolygon?

#4

you can try add some polygon colliders to the target node first, and check if the touch intersects with any of the colliders
try one collider first and see if that whats you want

#5

But the shape can be drawed in any part of the screen and i want to accept the form of any size

#6

Should not be to hard.

Make it simple:

Store the first touch as the center of the spiral. Store every other point in an array. Calculate the distance between the origin and each point.
Idealy every point has a slightly bigger distance to the center of the spiral. (work with some form of tolerance (even if some points are of it still counts as a spiral))
You can also calculate the angle between the touch and the center point, idealy again: all angles should increase (or decrease) steadily with some amount. 0 to 30 to 60 to 90 … to 360%360, to 390%360…

If the user actually starts from the outer edge, you have to get the last point and apply the same rules starting from the last point, ending at the first point.