Hi everyone,
I have a problem which requires me to detect whether a certain points is inside a triangle. Does cocos2d have certain method to help with this?
I've been thinking how to do a workaround with point in a rectangle detection function, but I can't since the 4 points registered will most likely won't have a shape of a parallelogram (It'll more likely form a shape of striped triangles with 2 of the points is squeezed together).
If you are interested to know what my problem is. It's something like this:
- I have a certain point at the center of the screen.
- The player will draw random curve on the screen.
- I'll have to detect whether there's any sprite is inside the shape formed by the certain point, the point at the tip of the curve, and the point at the end of the curve.
So far my idea is to subdivide the points on the curve into a few line segments. From these line segments I can form triangles with the certain point, and I could just do 4 times checks on each sprite's corners whether any of these 4 points is inside the triangles.
So, to reiterate my question, is there any method in cocos2d to do something like this?