put the virtual joystick into the userInputManager and restricted it to touchscreens

This commit is contained in:
kharhamel 2021-04-16 18:49:04 +02:00
parent d7a74baa9d
commit 56287a2958
5 changed files with 54 additions and 40 deletions

View file

@ -2,14 +2,20 @@ import {Pinch} from "phaser3-rex-plugins/plugins/gestures.js";
export class PinchManager {
private scene: Phaser.Scene;
private pinch!: any;
private pinch!: any; // eslint-disable-line
constructor(scene: Phaser.Scene) {
this.scene = scene;
this.pinch = new Pinch(scene);
this.pinch.on('pinch', (pinch:any) => {
this.scene.cameras.main.zoom *= pinch.scaleFactor;
this.pinch.on('pinch', (pinch:any) => { // eslint-disable-line
let newZoom = this.scene.cameras.main.zoom * pinch.scaleFactor;
if (newZoom < 0.25) {
newZoom = 0.25;
} else if(newZoom > 2) {
newZoom = 2;
}
this.scene.cameras.main.setZoom(newZoom);
});
}