working with zoom modifier calculating per zone

This commit is contained in:
Hanusiak Piotr 2021-12-02 17:46:09 +01:00
parent ddaa81a7ac
commit 37949eda53
4 changed files with 20 additions and 14 deletions

View file

@ -45,16 +45,16 @@ export class CameraManager extends Phaser.Events.EventEmitter {
this.waScaleManager.saveZoom();
this.restoreZoomTween?.stop();
const maxZoomModifier = 2.84; // How to get max zoom value?
const targetZoomModifier = this.waScaleManager.getTargetZoomModifierFor(focusOn.width, focusOn.height);
const currentZoomModifier = this.waScaleManager.zoomModifier;
const zoomModifierChange = maxZoomModifier - currentZoomModifier;
const zoomModifierChange = targetZoomModifier - currentZoomModifier;
this.camera.stopFollow();
this.camera.pan(
focusOn.x + focusOn.width * 0.5,
focusOn.y + focusOn.height * 0.5,
duration,
Easing.SineEaseOut, false, (camera, progress, x, y) => {
this.scene.setZoomModifierTo(currentZoomModifier + progress * zoomModifierChange);
this.waScaleManager.zoomModifier = currentZoomModifier + progress * zoomModifierChange;
});
}

View file

@ -1961,10 +1961,6 @@ ${escapedMessage}
biggestAvailableAreaStore.recompute();
}
public setZoomModifierTo(value: number): void {
waScaleManager.zoomModifier = value;
}
public createSuccessorGameScene(autostart: boolean, reconnecting: boolean) {
const gameSceneKey = "somekey" + Math.round(Math.random() * 10000);
const game = new GameScene(this.room, this.MapUrlFile, gameSceneKey);