- override
Evaluates this display object to see if the coordinates localX
and
localY
are inside this display object.
If the coordinates are inside, this display object is returned; null otherwise.
localX
and localY
are relative to to the origin (0,0) of this
display object (local coordinates).
Source
@override DisplayObject hitTestInput(num localX, num localY) { for (int i = 0; i < ixList.length - 2; i += 3) { int i1 = ixList[i + 0] << 2; int i2 = ixList[i + 1] << 2; int i3 = ixList[i + 2] << 2; num x1 = vxList[i1 + 0]; num y1 = vxList[i1 + 1]; num x2 = vxList[i2 + 0]; num y2 = vxList[i2 + 1]; num x3 = vxList[i3 + 0]; num y3 = vxList[i3 + 1]; if (localX < x1 && localX < x2 && localX < x3) continue; if (localX > x1 && localX > x2 && localX > x3) continue; if (localY < y1 && localY < y2 && localY < y3) continue; if (localY > y1 && localY > y2 && localY > y3) continue; num vx1 = x3 - x1; num vy1 = y3 - y1; num vx2 = x2 - x1; num vy2 = y2 - y1; num vx3 = localX - x1; num vy3 = localY - y1; num dot11 = vx1 * vx1 + vy1 * vy1; num dot12 = vx1 * vx2 + vy1 * vy2; num dot13 = vx1 * vx3 + vy1 * vy3; num dot22 = vx2 * vx2 + vy2 * vy2; num dot23 = vx2 * vx3 + vy2 * vy3; num u = (dot22 * dot13 - dot12 * dot23) / (dot11 * dot22 - dot12 * dot12); num v = (dot11 * dot23 - dot12 * dot13) / (dot11 * dot22 - dot12 * dot12); if ((u >= 0) && (v >= 0) && (u + v < 1)) return this; } return null; }