本文发表在 rolia.net 枫下论坛Say if I have some squares on the screen and I want to do a free draw,
when the line drawing crosses a square, I need to do something.
In the application, there is a OnMouseMove event, which is triggered
when the cursor moves from A to B.
what I am currently doing is,
1. when OnMouseMove event is triggered first time, I scanned all the squares to
see if the current moving point is in the square area, if yes, I
assume there is a line is "entering" the square
2. when OnMouseMove event is triggered again, I have know there is a
line entering a specific square, so this time I will check if the new
moving point is outside of the known square, if yes, I assume the line
has crossed the square
This idea works for most cases.
The only problem is, when the mouse moves too fast, from A and B, and
both points are outside a square, but actually the line can cross a
square, which means I was not aware there is an "entering" point.
So I wonder if anyone else can come up a better solution, thanks更多精彩文章及讨论,请光临枫下论坛 rolia.net
when the line drawing crosses a square, I need to do something.
In the application, there is a OnMouseMove event, which is triggered
when the cursor moves from A to B.
what I am currently doing is,
1. when OnMouseMove event is triggered first time, I scanned all the squares to
see if the current moving point is in the square area, if yes, I
assume there is a line is "entering" the square
2. when OnMouseMove event is triggered again, I have know there is a
line entering a specific square, so this time I will check if the new
moving point is outside of the known square, if yes, I assume the line
has crossed the square
This idea works for most cases.
The only problem is, when the mouse moves too fast, from A and B, and
both points are outside a square, but actually the line can cross a
square, which means I was not aware there is an "entering" point.
So I wonder if anyone else can come up a better solution, thanks更多精彩文章及讨论,请光临枫下论坛 rolia.net