This simple yet effective function with an example for the p5 library.
isInRange(sprite1,sprite2)
Uses Pythagoras' theorem to calculate actual distance between 2 sprites.
Returns true or false, depending on whether the 2 sprites or touching or not.