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;
|
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 maxZoomModifier = 2.84; // How to get max zoom value?
|
||||||
const currentZoomModifier = this.waScaleManager.zoomModifier;
|
const currentZoomModifier = this.waScaleManager.zoomModifier;
|
||||||
const zoomModifierChange = maxZoomModifier - currentZoomModifier;
|
const zoomModifierChange = maxZoomModifier - currentZoomModifier;
|
||||||
|
@ -43,6 +47,8 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public startFollow(target: object | Phaser.GameObjects.GameObject): void {
|
public startFollow(target: object | Phaser.GameObjects.GameObject): void {
|
||||||
|
this.waScaleManager.lockZoomingViaPlayerInput(false);
|
||||||
|
this.waScaleManager.restoreZoom();
|
||||||
this.camera.startFollow(target, true);
|
this.camera.startFollow(target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1954,6 +1954,9 @@ ${escapedMessage}
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomByFactor(zoomFactor: number) {
|
zoomByFactor(zoomFactor: number) {
|
||||||
|
if (waScaleManager.isZoomingViaPlayerInputLocked()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
waScaleManager.zoomModifier *= zoomFactor;
|
waScaleManager.zoomModifier *= zoomFactor;
|
||||||
biggestAvailableAreaStore.recompute();
|
biggestAvailableAreaStore.recompute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ export class WaScaleManager {
|
||||||
private actualZoom: number = 1;
|
private actualZoom: number = 1;
|
||||||
private _saveZoom: number = 1;
|
private _saveZoom: number = 1;
|
||||||
|
|
||||||
|
private zoomingViaPlayerInputLocked: boolean = false;
|
||||||
|
|
||||||
public constructor(private minGamePixelsNumber: number, private absoluteMinPixelNumber: number) {
|
public constructor(private minGamePixelsNumber: number, private absoluteMinPixelNumber: number) {
|
||||||
this.hdpiManager = new HdpiManager(minGamePixelsNumber, absoluteMinPixelNumber);
|
this.hdpiManager = new HdpiManager(minGamePixelsNumber, absoluteMinPixelNumber);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +23,14 @@ export class WaScaleManager {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isZoomingViaPlayerInputLocked(): boolean {
|
||||||
|
return this.zoomingViaPlayerInputLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public lockZoomingViaPlayerInput(lock: boolean = true): void {
|
||||||
|
this.zoomingViaPlayerInputLocked = lock;
|
||||||
|
}
|
||||||
|
|
||||||
public applyNewSize() {
|
public applyNewSize() {
|
||||||
const { width, height } = coWebsiteManager.getGameSize();
|
const { width, height } = coWebsiteManager.getGameSize();
|
||||||
|
|
||||||
|
|
|
@ -172,14 +172,14 @@
|
||||||
"y":96
|
"y":96
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":64,
|
"height":352,
|
||||||
"id":11,
|
"id":11,
|
||||||
"name":"coffeeZone",
|
"name":"meetingZone",
|
||||||
"properties":[
|
"properties":[
|
||||||
{
|
{
|
||||||
"name":"display_name",
|
"name":"display_name",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"Coffee Time!"
|
"value":"Brainstorm Zone!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"focusable",
|
"name":"focusable",
|
||||||
|
@ -189,9 +189,9 @@
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"zone",
|
"type":"zone",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":64,
|
"width":224,
|
||||||
"x":64,
|
"x":736,
|
||||||
"y":288
|
"y":96
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue