January 2018
Intermediate to advanced
678 pages
20h 16m
English
One thing we glossed over in the Point Tracker web page’s captureClick function is what happens when there are already two points and the user clicks the mouse to form another point. The point2 variable’s Point object gets moved to the point1 variable, and the new point created from the mouse click gets stored in the point2 variable. Here’s the code that implements that functionality:
point1 = point2; point2 = new Point(e.clientX, e.clientY);
That code might look pretty innocuous, but there’s a lot going on that deserves our attention. Remember that this code gets executed when there are already two points in existence. So the new operator creates a third point. When you first looked at that code in the ...
Read now
Unlock full access