Layer.getLayerAt

Function/Meaning

Get the layer at the specified position

Type
Layerclassmethod of
Syntax
getLayerAt(x, y, exclude_self=false, get_disabled=false)
Arguments
x

Specify the x-coordinate of the position of the layer you want to acquire in pixels on the display coordinates.
The display coordinates of the layer that executes this method are used (not the display coordinates on the primary layer).

y

Specify the y coordinate of the position of the layer you want to acquire in pixel units on the display coordinates.
The display coordinates of the layer that executes this method are used (not the display coordinates on the primary layer).

exclude_self

Specifies whether to exclude itself from the layer search.
If you specify false, your own layer is also included in the search.
If you specify true, your own layer is excluded from the search and treated as if it did not exist.
If this argument is omitted, false is assumed.

get_disabled

Specifies whether to get objects for layers that are disabled.
If false is specified, null is returned if a layer that is disabled (for example, the Layer.enabled property is false) is in the specified position.
If true is specified, if an invalid layer is in the specified position, that layer object is returned.
If this argument is omitted, false is assumed.

Return value

The layer object that was in the specified position.
Null is returned if there is no layer at the specified position.

Explanation

Returns the layer object at the position indicated by x, y.
The collision detection uses the same mechanism as the normal mouse event collision detection.
In other words, the specified position is viewed from the front in the layer stacking order, and the layer corresponding to the hit judgment is returned first.
You can exclude the layer that executes this method from the search by specifying true with the exclude_self argument.

Reference
Layer.hitType
Layer.hitThreshold
Layer.onHitTest