Touch

I’m new to Phaser 3 and I’m also a JavaScript novice, I wanted to detect a touch on the screen and perform an action therefore, but i’m finding the Phaser 3 touch system a bit confusing, could someone explain to me in more detail how it works?

Touch or mouse, they’re both “pointers” in Phaser and they use the same events. See the input/pointer examples.

Thank you very much for the answer, even so I still have doubts regarding ah that

To get global pointer events you need to use “this.input.on(string_event, callback, this)”

Callback is the function called when the event is triggered.

You can visit this link to learn the string_events you can use.
https://photonstorm.github.io/phaser3-docs/Phaser.Input.Events.html

To attach a pointer event to an object you need to use:
gameobject.setInteractive();
gameobject.on(string_event, callback, this);

Regards

1 Like

I found this to be the most helpful when I was starting out…

https://rexrainbow.github.io/phaser3-rex-notes/docs/site/touchevents/