Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to detect clicks on canvas elements which are drawn using paths. So far I have stored element paths in a JavaScript data structure and then check the coordinates of hits which match the element's coordinates. Rendering each element path and checking the hits would be inefficient when there are a lot of elements. I believe there must be an algorithm for this kind of coordinate search, can anyone help me with this?

share|improve this question
    
You can probably also try using pixel color for detection. As far i know EaselJS it in the algorithms –  Vishwas Gagrani Oct 4 '12 at 17:55
    
If you can name any algorithm particulary for this purpose or steps instead of library it would be nice. –  fallenAngel Oct 4 '12 at 20:43
    
I am not sure about the steps. But something like this : stackoverflow.com/questions/6735470/… can be used in the algorithm –  Vishwas Gagrani Oct 5 '12 at 5:17

1 Answer 1

You should probably take a look at engines that already do that like:

But I'm pretty sure they maintain some state relative to position and shape and check against those for every frame update.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.