I have noticed that using in a scene
this.input.on("pointerup", (event: Phaser.Input.Pointer) => {
console.log(event.button);
console.log(event.downX);
console.log(event.downY);
console.log(event.upX);
console.log(event.upY);
}, this);
Returns correct values when the event is triggered by mouse left click, but incorrect values when it’s middle or right click.
For example, right click on a just loaded scene will return 2 for the button and 0 for all the other values, no matter where you click on the scene.
samme
2
Per the docs, those values refer to left click only.
Ohh ok. I missed that.
The docs however is inaccurate in some aspects, for example it says for downX
X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects.
when in reality Button 1 is middle button, and Button 0 is really left button.
Also. Is there a reason for this? Why not return the coordinates for all pointer actions?
samme
4
Likely because dragging objects is by primary button only.
You can still get the pointer coordinates for any click: they’re in pointer.x
and pointer.y
.