locking zooming via player input
This commit is contained in:
parent
ef3a7513e2
commit
092daa245f
4 changed files with 26 additions and 7 deletions
|
@ -28,7 +28,11 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
|||
return this.camera;
|
||||
}
|
||||
|
||||
public changeCameraFocus(focusOn: { x: number, y: number, width: number, height: number }, duration: number = 1000): void {
|
||||
public changeCameraFocus(
|
||||
focusOn: { x: number, y: number, width: number, height: number }, duration: number = 1000,
|
||||
): void {
|
||||
this.waScaleManager.saveZoom();
|
||||
this.waScaleManager.lockZoomingViaPlayerInput();
|
||||
const maxZoomModifier = 2.84; // How to get max zoom value?
|
||||
const currentZoomModifier = this.waScaleManager.zoomModifier;
|
||||
const zoomModifierChange = maxZoomModifier - currentZoomModifier;
|
||||
|
@ -43,6 +47,8 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
|||
}
|
||||
|
||||
public startFollow(target: object | Phaser.GameObjects.GameObject): void {
|
||||
this.waScaleManager.lockZoomingViaPlayerInput(false);
|
||||
this.waScaleManager.restoreZoom();
|
||||
this.camera.startFollow(target, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1954,6 +1954,9 @@ ${escapedMessage}
|
|||
}
|
||||
|
||||
zoomByFactor(zoomFactor: number) {
|
||||
if (waScaleManager.isZoomingViaPlayerInputLocked()) {
|
||||
return;
|
||||
}
|
||||
waScaleManager.zoomModifier *= zoomFactor;
|
||||
biggestAvailableAreaStore.recompute();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ export class WaScaleManager {
|
|||
private actualZoom: number = 1;
|
||||
private _saveZoom: number = 1;
|
||||
|
||||
private zoomingViaPlayerInputLocked: boolean = false;
|
||||
|
||||
public constructor(private minGamePixelsNumber: number, private absoluteMinPixelNumber: number) {
|
||||
this.hdpiManager = new HdpiManager(minGamePixelsNumber, absoluteMinPixelNumber);
|
||||
}
|
||||
|
@ -21,6 +23,14 @@ export class WaScaleManager {
|
|||
this.game = game;
|
||||
}
|
||||
|
||||
public isZoomingViaPlayerInputLocked(): boolean {
|
||||
return this.zoomingViaPlayerInputLocked;
|
||||
}
|
||||
|
||||
public lockZoomingViaPlayerInput(lock: boolean = true): void {
|
||||
this.zoomingViaPlayerInputLocked = lock;
|
||||
}
|
||||
|
||||
public applyNewSize() {
|
||||
const { width, height } = coWebsiteManager.getGameSize();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue