Save zoom level of the game and restore it when quitting the login scenes

SelectCompanionScene with zoom on mobile
This commit is contained in:
GRL
2021-06-02 16:08:31 +02:00
parent 6fd119c199
commit 3d9e2ad49a
6 changed files with 40 additions and 14 deletions
+10 -6
View File
@@ -13,6 +13,8 @@ import { MenuScene } from "../Menu/MenuScene";
import { SelectCharacterSceneName } from "./SelectCharacterScene";
import {customCharacterSceneVisibleStore} from "../../Stores/CustomCharacterStore";
import {selectCharacterSceneVisibleStore} from "../../Stores/SelectCharacterStore";
import {waScaleManager} from "../Services/WaScaleManager";
import {isMobile} from "../../Enum/EnvironmentVariable";
export const CustomizeSceneName = "CustomizeScene";
@@ -52,11 +54,16 @@ export class CustomizeScene extends AbstractCharacterScene {
addLoader(this);
}
create() {
create(data: { from: string; }) {
customCharacterSceneVisibleStore.set(true);
this.events.addListener('wake', () => { customCharacterSceneVisibleStore.set(true); });
if (data.from === 'NoScene') {
//Save the zoom level only if the previous scene didn't already save it
waScaleManager.saveZoom();
}
waScaleManager.zoomModifier = isMobile() ? 2 : 1;
this.Rectangle = this.add.rectangle(this.cameras.main.worldView.x + this.cameras.main.width / 2, this.cameras.main.worldView.y + this.cameras.main.height / 3, 32, 33)
this.Rectangle.setStrokeStyle(2, 0xFFFFFF);
this.add.existing(this.Rectangle);
@@ -214,10 +221,6 @@ export class CustomizeScene extends AbstractCharacterScene {
this.containersRow[i][j].add(children);
}
}
}
update(time: number, delta: number): void {
}
public onResize(): void {
@@ -242,6 +245,7 @@ export class CustomizeScene extends AbstractCharacterScene {
gameManager.setCharacterLayers(layers);
this.scene.sleep(CustomizeSceneName);
waScaleManager.restoreZoom();
gameManager.tryResumingGame(this, EnableCameraSceneName);
customCharacterSceneVisibleStore.set(false);
}