working with zoom modifier calculating per zone
This commit is contained in:
parent
c09609f70c
commit
3e3a04d50e
@ -45,16 +45,16 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
|||||||
this.waScaleManager.saveZoom();
|
this.waScaleManager.saveZoom();
|
||||||
|
|
||||||
this.restoreZoomTween?.stop();
|
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 currentZoomModifier = this.waScaleManager.zoomModifier;
|
||||||
const zoomModifierChange = maxZoomModifier - currentZoomModifier;
|
const zoomModifierChange = targetZoomModifier - currentZoomModifier;
|
||||||
this.camera.stopFollow();
|
this.camera.stopFollow();
|
||||||
this.camera.pan(
|
this.camera.pan(
|
||||||
focusOn.x + focusOn.width * 0.5,
|
focusOn.x + focusOn.width * 0.5,
|
||||||
focusOn.y + focusOn.height * 0.5,
|
focusOn.y + focusOn.height * 0.5,
|
||||||
duration,
|
duration,
|
||||||
Easing.SineEaseOut, false, (camera, progress, x, y) => {
|
Easing.SineEaseOut, false, (camera, progress, x, y) => {
|
||||||
this.scene.setZoomModifierTo(currentZoomModifier + progress * zoomModifierChange);
|
this.waScaleManager.zoomModifier = currentZoomModifier + progress * zoomModifierChange;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,10 +1961,6 @@ ${escapedMessage}
|
|||||||
biggestAvailableAreaStore.recompute();
|
biggestAvailableAreaStore.recompute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public setZoomModifierTo(value: number): void {
|
|
||||||
waScaleManager.zoomModifier = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public createSuccessorGameScene(autostart: boolean, reconnecting: boolean) {
|
public createSuccessorGameScene(autostart: boolean, reconnecting: boolean) {
|
||||||
const gameSceneKey = "somekey" + Math.round(Math.random() * 10000);
|
const gameSceneKey = "somekey" + Math.round(Math.random() * 10000);
|
||||||
const game = new GameScene(this.room, this.MapUrlFile, gameSceneKey);
|
const game = new GameScene(this.room, this.MapUrlFile, gameSceneKey);
|
||||||
|
@ -24,10 +24,7 @@ export class WaScaleManager {
|
|||||||
public applyNewSize() {
|
public applyNewSize() {
|
||||||
const { width, height } = coWebsiteManager.getGameSize();
|
const { width, height } = coWebsiteManager.getGameSize();
|
||||||
|
|
||||||
let devicePixelRatio = 1;
|
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
||||||
if (window.devicePixelRatio) {
|
|
||||||
devicePixelRatio = window.devicePixelRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { game: gameSize, real: realSize } = this.hdpiManager.getOptimalGameSize({
|
const { game: gameSize, real: realSize } = this.hdpiManager.getOptimalGameSize({
|
||||||
width: width * devicePixelRatio,
|
width: width * devicePixelRatio,
|
||||||
@ -59,6 +56,19 @@ export class WaScaleManager {
|
|||||||
this.game.markDirty();
|
this.game.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTargetZoomModifierFor(viewportWidth: number, viewportHeight: number) {
|
||||||
|
const { width: gameWidth, height: gameHeight } = coWebsiteManager.getGameSize();
|
||||||
|
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
||||||
|
|
||||||
|
const { game: gameSize, real: realSize } = this.hdpiManager.getOptimalGameSize({
|
||||||
|
width: gameWidth * devicePixelRatio,
|
||||||
|
height: gameHeight * devicePixelRatio,
|
||||||
|
});
|
||||||
|
// P.H. Note: Dunno where this magic 2 comes from
|
||||||
|
// Always return lowest possible value. Need to add MAX ZOOM MODIFIER value into this.
|
||||||
|
return Math.min(realSize.width / viewportWidth / 2, realSize.height / viewportHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
public get zoomModifier(): number {
|
public get zoomModifier(): number {
|
||||||
return this.hdpiManager.zoomModifier;
|
return this.hdpiManager.zoomModifier;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
"y":0
|
"y":0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data":[201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 212, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 212, 212, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201],
|
"data":[201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 223, 223, 223, 223, 223, 223, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201],
|
||||||
"height":17,
|
"height":17,
|
||||||
"id":4,
|
"id":4,
|
||||||
"name":"floor",
|
"name":"floor",
|
||||||
@ -172,7 +172,7 @@
|
|||||||
"y":96
|
"y":96
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":352,
|
"height":416,
|
||||||
"id":11,
|
"id":11,
|
||||||
"name":"meetingZone",
|
"name":"meetingZone",
|
||||||
"properties":[
|
"properties":[
|
||||||
@ -191,7 +191,7 @@
|
|||||||
"visible":true,
|
"visible":true,
|
||||||
"width":224,
|
"width":224,
|
||||||
"x":736,
|
"x":736,
|
||||||
"y":96
|
"y":32
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
|
Loading…
Reference in New Issue
Block a user