How to detect collision on a polyline

Hello,

I have been fighting with that for a few days, but I find no solution. In my game, I have a path made of a polyline. I need that the user’s finger keeps on the path. If it gets out of the path, game over. I need it to be a polyline, as I think it is the easiest way to draw different paths.

As the path is a polyline, I cannot check the touch coorinates with the polyline center. So any coordinate checking is useless (I think). Maybe if I build an invisible cilrcle and check if it is on the polyline, it would work, but I have no idea how to make this.

Anyone could help me? Anyone could send me some simple code that do this with polylines?

Thank you very much in advance! [import]uid: 40363 topic_id: 7728 reply_id: 307728[/import]

Try creating a list (table) of xy points between the segments, then each finger movement, iterate thru array, checking each point for intersection with a test rect corresponding to the finger touch area. Or you could do a more accurate distance check, but you’d be doing a square root calc for each point. [import]uid: 3953 topic_id: 7728 reply_id: 27731[/import]

Hi,

Thank you but it is a lot of work as I have different polylines with more than 20 lines each.

I thought of programing a collision without physics, but I have no idea how to do it. If I have a small circle following th finger (linked to the touch coordinates), how coul I check if it overlaps the polyline (it collides with it)? Woul it work? Any short example with a two line polyline? Anyone could help me please?

Thank you!!!
[import]uid: 40363 topic_id: 7728 reply_id: 27843[/import]