I would like to see how to detect when touch event has entered the zone of an entity? say within 20 pixels of its image border.
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.
One solution is to include a transparent border around the image. The touch still triggers when it’s on the transparent areas. So, for example:
A touch on the transparent area around the ball will fire the touch event listener. For a circle, you can even check the distance from the touch to the center of the circle, and ignore any that are “too far” from the center, giving a circular response zone. If your image isn’t circular, you may need more complex validation logic, but at least you’ll get the touch event.