When I was working on my mobile game, my testers found out that its touch control didn't work. After my investigation, I discovered that the pointer/touch input just dosen't work on the first scene using mobile devices. All of the scenes after work perfectly fine. Also, if I load some web fonts inside the create() function of the scene, there will be a short period of time that the touch input will work.
The problem is the assignment of activePointer to a local property, which you then check in the update loop. The activePointer is not set on a touch device until you actually touch it, so you're basically binding and checking the mouse pointer (which doesn't do anything on mobile) in your code.
Swap the code in your Scene 1 update loop so it says: this.input.activePointer.isDown and it'll start doing as you expect. Once the scene has been touched, anyway.
Thanks for your help!
No worries - perhaps you could suggest somewhere I can add this in the docs to make it more obvious?
Hello photonstorm
I am using phaser3. I am developing a shooter game in mobile. I have set buttons for movement and a button for shooting. while the movement button is down and if i press shoot button its not working. but if i release movement button i can shoot. i played with activePointer and pointer1 and 2 with 2 active pointer in config. but its not working. please help.
Thank you for the wonderful framework, hope i can earn some day.. :-)
Hey Photonstorm
Got the solution. Just giving active pointers :2 in config doesnt do the trick(and in some article it says 2 is by default).
we need to add
this.input.addPointer(2) //or as 3 as needed
Lucky charm
Thank you
Most helpful comment
The problem is the assignment of
activePointerto a local property, which you then check in theupdateloop. TheactivePointeris not set on a touch device until you actually touch it, so you're basically binding and checking the mouse pointer (which doesn't do anything on mobile) in your code.Swap the code in your Scene 1 update loop so it says:
this.input.activePointer.isDownand it'll start doing as you expect. Once the scene has been touched, anyway.