finkophonium Posted April 8, 2014 Share Posted April 8, 2014 Hi, I'm trying to write a mobile game using Phaser and CocoonJS, but I'm having some trouble getting touch events to fire. Right now I have a very simple event set up as follows:game.input.onDown.add(click, this);with "click" being the function used to handle interactions. This works fine in the browser, but it isn't triggering at all with touch. Is there some other input I'm supposed to be using for touch events? Or, better yet, an event that recognizes both click and touch events? I've also tried usinggame.input.touch.touchStartCallback = click;but I had no luck with that either. Any help would be appreciated. Link to comment Share on other sites More sharing options...
rich Posted April 9, 2014 Share Posted April 9, 2014 I tend to just use:game.input.activePointer.onDown.add(handler, context);This will handle both mouse and touch without you needing to do anything else. I don't know if it works on Cocoon, but it definitely works in mobile browsers. Link to comment Share on other sites More sharing options...
finkophonium Posted April 9, 2014 Author Share Posted April 9, 2014 Thanks, but when I try that, I get "Cannot call method 'add' of undefined." It appears that the Pointer class doesn't have an onDown property. Is there another way to do this? Link to comment Share on other sites More sharing options...
Heppell08 Posted April 9, 2014 Share Posted April 9, 2014 activePointer.isDown is what you're looking for. Link to comment Share on other sites More sharing options...
rich Posted April 10, 2014 Share Posted April 10, 2014 Sorry yes - activePointer.isDown (a boolean, not an event) as Heppell said, or input.onDown.add - which IS an event and gets fired by mouse or touch, regardless of which causes it. Heppell08 1 Link to comment Share on other sites More sharing options...
Recommended Posts