From fbb44af369e80b37b83905098143f24f6a4f3132 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Wed, 6 Jan 2021 17:08:48 +0100 Subject: [PATCH] added a basic loader --- front/src/Phaser/Game/GameScene.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 99b002de..1357f6d8 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -180,6 +180,8 @@ export class GameScene extends ResizableScene implements CenterListener { //hook preload scene preload(): void { + this.initProgressBar(); + this.load.image(openChatIconName, 'resources/objects/talk.png'); this.load.on(FILE_LOAD_ERROR, (file: {src: string}) => { this.scene.start(FourOFourSceneName, { @@ -206,6 +208,16 @@ export class GameScene extends ResizableScene implements CenterListener { this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml'); } + private initProgressBar(): void { + const progress = this.add.graphics(); + this.load.on('progress', (value: number) => { + progress.clear(); + progress.fillStyle(0xffffff, 1); + progress.fillRect(0, 270, 800 * value, 60); + }); + this.load.on('complete', () => progress.destroy()); + } + // FIXME: we need to put a "unknown" instead of a "any" and validate the structure of the JSON we are receiving. // eslint-disable-next-line @typescript-eslint/no-explicit-any private async onMapLoad(data: any): Promise {