I already experimented a bit with enumerateBodiesInRect , and I found it incredibly inaccurate. It seems that it doesnβt have any declared functionality, but instead gets a random result. I honestly cannot even identify any sample from my products.
enumerateBodiesAlongRay seems better, but still very buggy. The problem with this function, apparently, is the conversion between the coordinates of the screen and physics. I would have avoided that too.
I think your solution should simply be to use your existing contact detection system. All necessary functions can be written in the didBeginContact() and didEndContact() functions. This has the added benefit of allowing you to specify various functionalities for entering and exiting the area. You can also add particle effects, animations, etc., and also intentionally ignore certain types of nodes.
The only thing needed for the success of this method is to clarify that the contact area has a unique category, that contactTestBitMask contains all the nodes you need, and collisionBitMask contains 0.
source share