Jump to content

How to trigger both touch and click events?


finkophonium
 Share

Recommended Posts

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 using

game.input.touch.touchStartCallback = click;

but I had no luck with that either. Any help would be appreciated.

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

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