Jump to content

Distinguishing clicks


wichiwichi
 Share

Recommended Posts

I mean there's a click that lasts of x seconds, then there's no click, then another click that lasts for another x seconds. Is there a value/identifier to distinguish one click from another?

 

I've got a sprite that is clicked for several seconds and I want to capture the next click, so I want to do something like:

 

if (isClick && isDifferentFromLastClick)

 

 

 

Sorry for not being very clear, I don't know how to express it

Link to comment
Share on other sites

No, I'm afraid not, but you can do this easily yourself. If all you want is to ensure that each click is unique, you could just store the number of clicks as a value, and increment it each time the click handler is called, though I don't see how this is any different from just doing something each time the click handler is called anyway - since each call is a unique click!

 

If you want a bit more sophistication, you could add a small timer which increments the counter only if a specified period of time has passed since the last click: http://jsfiddle.net/lewster32/cGCLS/

Link to comment
Share on other sites

Thanks!

 

I think one of my problems was that inside the update function I had a click for each frame, so I couldn't tell apart what was still the same click. But I think with the counter example I can get over it. I didn't think about it

 

thanks again!!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...