From ff17c51286c84ea53b22758c8dd8132ea26449bf Mon Sep 17 00:00:00 2001 From: Hyun Ahn Date: Tue, 21 Nov 2023 03:59:02 +0900 Subject: [PATCH] save --- src/loading-scene.ts | 149 ++++++++++++++++++++++--------------------- src/main.ts | 14 +++- 2 files changed, 86 insertions(+), 77 deletions(-) diff --git a/src/loading-scene.ts b/src/loading-scene.ts index 0c8580cf368..80653ed6690 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -8,95 +8,96 @@ class LoadingScene extends Phaser.Scene { } loadLoadingScreen() { - let progressBar = this.add.graphics(); - let progressBox = this.add.graphics(); - progressBox.fillStyle(0x222222, 0.8); + const graphics = this.add.graphics(); - let width = this.cameras.main.width; - let height = this.cameras.main.height; + graphics.lineStyle(4, 0xff00ff, 1).setDepth(10); - let loadingText = this.make.text({ - x: width / 2, - y: height / 2 - 50, - text: "Loading...", - style: { - font: "20px emerald", - color: "#ffffff", - }, - }); - loadingText.setOrigin(0.5, 0.5); + // let progressBar = this.add.graphics(); + // let progressBox = this.add.graphics(); + // progressBox.lineStyle(5, 0xff00ff, 1.0); + // progressBox.fillStyle(0x222222, 0.8); - let percentText = this.make.text({ - x: width / 2, - y: height / 2, - text: "0%", - style: { - font: "18px emerald", - color: "#ffffff", - }, - }); - percentText.setOrigin(0.5, 0.5); + // let width = this.cameras.main.width; + // let height = this.cameras.main.height; - let assetText = this.make.text({ - x: width / 2, - y: height / 2 + 50, - text: "", - style: { - font: "18px monospace", - color: "#ffffff", - }, - }); - assetText.setOrigin(0.5, 0.5); + // let loadingText = this.make.text({ + // x: width / 2, + // y: height / 2 - 50, + // text: "Loading game...", + // style: { + // font: "23px emerald", + // color: "#ffffff", + // }, + // }); + // loadingText.setOrigin(0.5, 0.5); - this.load.on("progress", (value: string) => { - const parsedValue = parseInt(value); - percentText.setText(parsedValue * 100 + "%"); - progressBar.clear(); - progressBar.fillStyle(0xffffff, 0.8); - progressBar.fillRect( - this.gameWidth / 2 - 160, - 280, - 300 * parsedValue, - 30 - ); - }); + // let percentText = this.make.text({ + // x: width / 2, + // y: height / 2, + // text: "0%", + // style: { + // font: "18px emerald", + // color: "#ffffff", + // }, + // }); + // percentText.setOrigin(0.5, 0.5); - this.load.on("fileprogress", (file) => { - assetText.setText("Loading asset: " + file.key); - }); + // let assetText = this.make.text({ + // x: width / 2, + // y: height / 2 + 50, + // text: "", + // style: { + // font: "18px emerald", + // color: "#ffffff", + // }, + // }); + // assetText.setOrigin(0.5, 0.5); - this.load.on("complete", () => { - progressBar.destroy(); - progressBox.destroy(); - loadingText.destroy(); - percentText.destroy(); - assetText.destroy(); - }); + // this.load.on("progress", (value: string) => { + // const parsedValue = parseInt(value); + // percentText.setText(parsedValue * 100 + "%"); + // progressBar.clear(); + // progressBar.fillStyle(0xffffff, 0.8); + // progressBar.fillRect(width / 2 - 160, 280, 300 * parsedValue, 30); + // }); + + // this.load.on("fileprogress", (file) => { + // assetText.setText("Loading asset: " + file.key); + // }); + + // this.load.on("complete", () => { + // progressBar.destroy(); + // progressBox.destroy(); + // loadingText.destroy(); + // percentText.destroy(); + // assetText.destroy(); + // }); } - isLocal() { - return location.hostname === "localhost" || - location.hostname === "127.0.0.1" - ? true - : false; - } + // isLocal() { + // return location.hostname === "localhost" || + // location.hostname === "127.0.0.1" + // ? true + // : false; + // } - gameHeight() { - return game.config.height as number; - } + // get gameHeight() { + // return this.game.config.height as number; + // } - gameWidth() { - return game.config.width as number; - } + // get gameWidth() { + // return this.game.config.width as number; + // } - create() { - // const logoExposeSetting: number = this.isLocal ? 300 : 2000; + async create() { + // const logoExposeSetting: number = this.isLocal() ? 500 : 2000; // this.cameras.main.fadeIn(1000, 255, 255, 255); - // setTimeout(() => { - // this.scene.start("battle"); - // }, logoExposeSetting); + + setTimeout(() => { + this.scene.start("battle"); + }, 500); } } diff --git a/src/main.ts b/src/main.ts index 0a4c2910320..df39020aa6d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,16 +6,25 @@ import InvertPostFX from './pipelines/invert'; const config: Phaser.Types.Core.GameConfig = { type: Phaser.WEBGL, parent: 'app', + backgroundColor: 'transparent', scale: { width: 1920, height: 1080, mode: Phaser.Scale.FIT }, pixelArt: true, - pipeline: [ InvertPostFX ] as unknown as Phaser.Types.Core.PipelineConfig, - scene: [ LoadingScene, BattleScene ] + pipeline: [ InvertPostFX ] as unknown as Phaser.Types.Core.PipelineConfig }; +const game = new Phaser.Game( + Object.assign(config, { + scene: [ + LoadingScene, + BattleScene, + ] + }) +) + const setPositionRelative = function (guideObject: any, x: number, y: number) { if (guideObject && guideObject instanceof Phaser.GameObjects.GameObject) { const offsetX = guideObject.width * (-0.5 + (0.5 - guideObject.originX)); @@ -34,7 +43,6 @@ Phaser.GameObjects.Text.prototype.setPositionRelative = setPositionRelative; document.fonts.load('16px emerald').then(() => document.fonts.load('10px pkmnems')); -const game = new Phaser.Game(config); game.sound.pauseOnBlur = false; export default game; \ No newline at end of file