Reicher Posted July 25, 2015 Share Posted July 25, 2015 I'm working on a little game(http://trans-neptunian-studios.com/Snatris/Beta/) that uses Phaser 2.3.0. In my game i have a chain of connected lines segments (Phaser.Line). I want to detect when any of these segments intersect. I have found a problem with how Phaser.Line.intersects work. A simple example: var line1 = new Phaser.Line(0, 0, 100, 0);var line2 = new Phaser.Line(40, 0, 60, 0);console.log(line1.intersects(line2));console.log(line2.intersects(line1));The two segments line1 and line2 are not only parallel but also on top of each other. Phaser.Line.intersects does not recognize this type of intersection. I understand that in a pure "math-sense" parallel lines cannot intersect or rather they do intersect on infinite many places.What is the easiest way to detect the "intersection"? Keep in mind that I have many lines in my game and need a general solution. Link to comment Share on other sites More sharing options...
wayfinder Posted July 25, 2015 Share Posted July 25, 2015 You could put in a check whether any of the end points of a line fall on the other with line.pointOnSegment. That would catch all of these cases. d13 1 Link to comment Share on other sites More sharing options...
Recommended Posts