getObjectsUnderPoint method

List<DisplayObject> getObjectsUnderPoint(
  1. Point<num> point
)

Returns a list of display objects that lie under the specified point and are children (or grandchildren, and so on) of this display object container.

The point parameter is in the local coordinate system of this display object container.

Implementation

List<DisplayObject> getObjectsUnderPoint(Point<num> point) {
  final result = <DisplayObject>[];
  final temp = Point<num>(0.0, 0.0);

  for (var child in _children) {
    child.parentToLocal(point, temp);
    if (child is DisplayObjectContainer) {
      result.addAll(child.getObjectsUnderPoint(temp));
    } else if (child.bounds.contains(temp.x, temp.y)) {
      result.add(child);
    }
  }

  return result;
}