Default number of pointers?

Hi there, I just wanted to check if I am I getting the pointer situation in Phaser correct.

According to the docs 2 pointers are created by default (https://photonstorm.github.io/phaser3-docs/Phaser.Input.Pointer.html).

If I console.log:

this.input.manager.pointersTotal

then it prints out 2, as expected. However in my code when I check for pointer2:

e.g.

if(this.input.pointer2.isDown)

No joy. If I add another pointer either in my create function like this:

this.input.addPointer(1);

Or by specifying 3 pointers in the config like this:

  var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 400,
    input: {
      activePointers: 3
    },
    physics: {
      default: 'arcade',
      arcade: {
        gravity: { y: 300 }
      }
    },
    scene: {
      preload: preload,
      create: create,
      update: update
    }
  };

Then I can use multitouch (i.e. two fingers at once) and pointer2.isDown fires as I’d expect. It all works nicely I’m just confused by needing 3 pointers instead of 2? If 2 pointers are registered by default, why am I have to register a third in order to have 2 pointers? Any ideas?

The 2 pointers are this.input.mousePointer and this.input.pointer1.

If you check this.input.manager.pointers you will see it has 2 pointers, and if you look at the source code this.input.pointer1 is a reference to the 2nd pointer.

2 Likes

Legend, thank you! That had been bothering me all day.