Phaser 2.0.5 input not working Android

Recommended Posts

Hi all,


I noticed that input isn't working on stock Android ( namely older devices like the Nexus S ). It seems officially touch events aren't supposed to work - using mouse instead, and Chrome's device emulation confirms that. This can be fixed by checking if the device is touch in the Phaser Mouse start function:

if (this.game.device.android && this.game.device.chrome === false && this.game.device.touch)

And this fixes it in Chrome, but it's still not working on the device. I've tried a bunch of things, but even the touch and mouse events aren't triggering. We've previously built a game on Phaser 1.1.6 and everything works correctly on the same device.


Anyone have any ideas? Even an idea on how to debug this besides console logging would be useful.



David Goemans

Lead game dev @ Boostermedia

Share this post

Link to post
Share on other sites

Are you sure touchevents don't work on stock Android browser? (I don't mean in Phaser, I just mean in general). It seems highly unlikely to me that it would expect mouse events instead. Is there a boiled down test case you've got at all? I have a first generation Nexus 1 here, time to charge it up I guess.

Share this post

Link to post
Share on other sites

Thanks for the response Richard...

I'm not sure to be honest. I read some documentation online saying earlier Android stock didn't respond to touch events and only used mouse events, but i quickly made a test with touchstart and mousedown events attached to a canvas element, and it seems that's working as expected. I still have no idea why our game refuses to detect the events. I ran it again on the Phaser samples, and although it had some issues at first it also seems to be working. We're not overriding any of the listeners, but can you think of anything that might interfere with the touch events?


PS: I'd still like that code i posted to be considered for phaser, since it helps chrome debugging a lot.

Share this post

Link to post
Share on other sites

I know early Android devices only support 1 touch event and don't support multi touch, so it'd make sense to lock the input handlers down to 1:

this.input.maxPointers = 1;

(in your Boot state)


But it could also be related to this lovely classic Android bug too. Either way I'll boot the nexus 1 now and see, although I'm sure it's so old it won't let me install Chrome anyway.

Share this post

Link to post
Share on other sites

OK, found it. Took me all day, but here it is:


In Android stock ( i can confirm 4.1.2 Nexus S ), if you have another div with the following css:

display : none;z-index : -1;pointer-events : none;

Because of the display: none, it discards the z-index and pointer-events on load, and so ignores them when you set the div to display again. We were using this to render a background on a separate layer under the game. The solution i'm going to use is to start it as a block, set it to none, and then set it back to block when i need to see it. This seems to work.


I'll file this under... yet another stock Android issue :)


Thanks for the help!


( oh and as a side note, you can't add the pointer-events: none; later in javascript, as this doesn't work in Firefox )

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.