From a724d80bb726fea8e660367a153d191da93c9ff5 Mon Sep 17 00:00:00 2001 From: KGrzeg Date: Sun, 17 Oct 2021 18:16:38 +0200 Subject: [PATCH] Start Screen --- src/index.html | 2 +- src/main.ts | 3 ++- src/scenes/PlayScene.ts | 6 +++++- src/scenes/StartScene.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 src/scenes/StartScene.ts diff --git a/src/index.html b/src/index.html index 4f83160..fa322fa 100644 --- a/src/index.html +++ b/src/index.html @@ -1,7 +1,7 @@ - Miner + SPACE SMASHER 9001! diff --git a/src/main.ts b/src/main.ts index 1d3afb0..2cc63d8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import Phaser, { Game } from 'phaser' import PlayScene from './scenes/PlayScene' import GameOverScene from './scenes/GameOverScene' +import StartScene from './scenes/StartScene' const config: Phaser.Types.Core.GameConfig = { type: Phaser.AUTO, @@ -15,7 +16,7 @@ const config: Phaser.Types.Core.GameConfig = { debug: false } }, - scene: [PlayScene, GameOverScene] + scene: [StartScene, PlayScene, GameOverScene] } export default new Phaser.Game(config) diff --git a/src/scenes/PlayScene.ts b/src/scenes/PlayScene.ts index 5d28020..d107991 100644 --- a/src/scenes/PlayScene.ts +++ b/src/scenes/PlayScene.ts @@ -16,6 +16,7 @@ export default class PlayScene extends Phaser.Scene { backgroundOrder: number[] = [] backgroundId = 0 startTimestamp: number = 0 + auth: any constructor() { super('play-scene') @@ -35,7 +36,10 @@ export default class PlayScene extends Phaser.Scene { this.load.multiatlas('asteroids', 'assets/img/asteroids.json', 'assets/img'); } - create() { + create(data) { + console.log("Started game with", data) + this.auth = data + Asteroid.createAnimations(this) this.difficulty = new DifficultyManager(this) this.events.on('getpoint', this.updateLabel, this) diff --git a/src/scenes/StartScene.ts b/src/scenes/StartScene.ts new file mode 100644 index 0000000..de75eeb --- /dev/null +++ b/src/scenes/StartScene.ts @@ -0,0 +1,40 @@ +import Phaser from 'phaser' + +export default class StartScene extends Phaser.Scene { + + constructor() { + super('start-scene') + } + + preload() { + this.load.image('phaser-logo', 'assets/img/phaser3-logo.png') + this.load.image('hs3-logo', 'assets/img/hs3-logo.png') + } + + create() { + this.add.image(250, 550, 'phaser-logo').setScale(0.5) + this.add.image(550, 550, 'hs3-logo').setScale(0.5) + + this.add.text( + this.cameras.main.centerX, + this.cameras.main.centerY - 100, + "SPACE SMASHER 9001!", { + font: '64px Verdana', + }).setOrigin(0.5, 0.5) + + this.add.text(this.cameras.main.centerX, this.cameras.main.centerY, [ + "Naciśnij przycisk aby zacząć", + "", + "Zaloguj się przed rozpoczęciem gry, aby zachować rekord", + "albo graj jako gość (bez rankingu)" + ], { + font: '21px Verdana', + align: 'center', + color: 'cyan' + }).setOrigin(0.5, 0.5) + + this.input.on('pointerup', () => { + this.scene.start('play-scene', window.myStuff); + }); + } +}