I am developing a tree game and having dots to add branches on the tree, I want to enhance it for e.g. when one dot get a click then it display other dots within a particular radius around it.
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.
From the description you’ve given, I think you are looking for Distance Formula.
Sqrt((y2-y1)^2 + (x2-x1)^2)For example:
You have a radius defined and an array of dots:
The dot being clicked is (5,5) and suppose you have a determined radius r=20.
Now, to get all the dots withing the radius r, by iterating in the dots:
I haven’t tested the code but I really hope this gives you an understanding.