Hey, looking to read the force field of touch events for a drawing app. Has anyone done this before?
Seems you can use pointer.event.pressure
within an event handler.
With this in my scene.create():
this.input.manager.canvas.addEventListener('touchmove', (event) => {
(window as any).debugLog(`touchmove event=${JSON.stringify(event)}`);
});
All I see is "touchmove event={“isTrusted”: true}. More verbose logging like the below yields nothing but undefineds.
With this instead:
this.input.on(
"pointermove",
(pointer: Phaser.Input.Pointer) => {
// (window as any).debugLog(`pointermove: p=${JSON.stringify(pointer)}`); // only prints isTRusted, but there are other fields.
console.log(pointer.event); // This at least shows whole event.
// Undefined even on iPad.
(window as any).debugLog(`pointermove: force=${pointer.event.force}, pressure=${pointer.event.pressure}, prototype ${Object.getPrototypeOf(pointer.event)}, pointer.event.keys=${Object.keys(pointer.event)}`);
}
);
I see:
force=undefined pressure=undefined prototype [object TouchEvent], pointer.event.keys=isTrusted.
I’m testing on both iPad Safari and Android Chrome so I don’t think it’s a browser issue.
Ahah, it’s under .touches.force. This works:
this.input.on(
"pointermove",
(pointer: Phaser.Input.Pointer) => {
(window as any).debugLog(`pointermove: pointer.event.touches.force=${JSON.stringify(pointer.event.touches[0].force)}`);
}
);