Adding HdpiManager to start and scale from a default resolution that is correct by default for the game.
Fixing VirtualJoystick on resize.
This commit is contained in:
parent
6a2326c4b3
commit
04d3cf8593
9 changed files with 213 additions and 32 deletions
|
@ -1,22 +1,20 @@
|
|||
import {Pinch} from "phaser3-rex-plugins/plugins/gestures.js";
|
||||
import {waScaleManager} from "../Services/WaScaleManager";
|
||||
|
||||
export class PinchManager {
|
||||
private scene: Phaser.Scene;
|
||||
private pinch!: any; // eslint-disable-line
|
||||
|
||||
|
||||
constructor(scene: Phaser.Scene) {
|
||||
this.scene = scene;
|
||||
this.pinch = new Pinch(scene);
|
||||
|
||||
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);
|
||||
waScaleManager.zoomModifier *= pinch.scaleFactor;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.pinch.removeAllListeners();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue