Is there a (simple) way to return the amount of elements colliding with a single element? Perhaps with jQuery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The HTML DOM doesn’t give us a clean way of finding all elements colliding (or overlapping) with a given element.
The only real way to do it is to check x/y positioning and height/width of each element to calculate collisions geometrically. It’s obviously slow if you are checking all elements on a decent sized page.
There are plugins to make this easier to manage. gameQuery has a collision function that encapsulates all the logic for you. I’m sure there are other plugins as well.