Crafty.findPointerEventTargetByComponent()

public Object .findPointerEventTargetByComponent(String comp, Number clientX, Number clientY)

Finds closest entity with certain component at a given position.

comp

Component name

clientX

x coordinate in client space, usually taken from a pointer event

clientY

y coordinate in client space, usually taken from a pointer event

[Returns]

The found entity, or null if no entity was found.

public Object .findPointerEventTargetByComponent(String comp, Event e)

Finds closest entity with certain component at a given event.

comp

Component name

e

The pointer event, containing the target and the required properties clientX & clientY, which will be used as the query point

[Returns]

The found entity, or null if no entity was found.

This method is used internally by the .mouseDispatch and .touchDispatch methods, but can be used otherwise for Canvas entities.

Finds the top most entity (with the highest z) with a given component at a given point (x, y). For having a detection area specified for the enity, add the AreaMap component to the entity expected to be found.