public this .findPointerEventTargetByComponent(String comp, Event e[, Object target])

Finds closest entity with certain component at a given event.


Component name


The pointer event, which will be modifed to add realX and realY properties


Target element wherein to look for entities

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) associated with the event. For having a detection area specified for the enity, add the AreaMap component to the entity expected to be found.

The 'target' argument is only meant to be used by .mouseDispatch and touchDispatch; defaults to Crafty.stage.elem, thus using this function directly is only worth anything for canvas entities.

Returns the found entity, or undefined if no entity was found. Updates the event object to have two additional properties, realX and realY, which correspond to the point in the Crafty layer that the event targeted.