wichiwichi Posted July 31, 2014 Share Posted July 31, 2014 Hi there! Is there a unique identifier so I can distinguish one click from another? This doesn't seem to be what I'm looking for http://docs.phaser.io/Phaser.Pointer.html#identifier Link to comment Share on other sites More sharing options...
lewster32 Posted July 31, 2014 Share Posted July 31, 2014 How do you mean distinguish clicks? Do you mean determine multiple fingers when doing multitouch? Link to comment Share on other sites More sharing options...
wichiwichi Posted July 31, 2014 Author Share Posted July 31, 2014 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 More sharing options...
lewster32 Posted July 31, 2014 Share Posted July 31, 2014 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 More sharing options...
wichiwichi Posted July 31, 2014 Author Share Posted July 31, 2014 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 More sharing options...
lewster32 Posted July 31, 2014 Share Posted July 31, 2014 Ah I see - for discreet events like this you should be using the onDown and similar events rather than polling the isDown properties I think, as the latter is meant for continuous inputs such as rapid firing, thrust or moving. Link to comment Share on other sites More sharing options...
Recommended Posts