2021-04-14 17:47:26 +02:00
|
|
|
import {Pinch} from "phaser3-rex-plugins/plugins/gestures.js";
|
|
|
|
|
|
|
|
export class PinchManager {
|
|
|
|
private scene: Phaser.Scene;
|
2021-04-16 18:49:04 +02:00
|
|
|
private pinch!: any; // eslint-disable-line
|
2021-04-14 17:47:26 +02:00
|
|
|
|
|
|
|
constructor(scene: Phaser.Scene) {
|
|
|
|
this.scene = scene;
|
|
|
|
this.pinch = new Pinch(scene);
|
|
|
|
|
2021-04-16 18:49:04 +02:00
|
|
|
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);
|
2021-04-14 17:47:26 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|