1
我想弄清楚如何檢測處理/處理js時鼠標在屏幕上的某個對象。在這種情況下,我正在畫線。看起來處理不能將「監聽器」附加到對象上,所以我必須通過某種座標檢測來完成此操作 - 但我還沒有找到任何這方面的好例子。這是到目前爲止我的代碼:處理 - mouseOver對象
void draw() {
for(int i = 0; i < commLength; i ++) {
...
line(circ.x, circ.y, circ.x + dir.x, circ.y + dir.y);
}
}
void mouseOver(){
//need to detect if mouse is over one of the lines.
}