diff --git a/package.json b/package.json index 2c82774..448745e 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ "predeploy": "npm run build", "deploy": "gh-pages -d dist", "preview": "vite preview" - }, - + }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.40.0", "@typescript-eslint/parser": "^5.40.0", diff --git a/src/Scenes/HelloWorldScene.ts b/src/Scenes/HelloWorldScene.ts index 75b4e57..b810ea7 100644 --- a/src/Scenes/HelloWorldScene.ts +++ b/src/Scenes/HelloWorldScene.ts @@ -6,6 +6,8 @@ import Button from '../Objects/Button'; import Player from '../Objects/Player'; //import Player from "./Objects/Player"; +import { TextButtonObject } from "../Objects/TextButtonObject"; + export default class HelloWorldScene extends Phaser.Scene { //Sprite creation @@ -24,6 +26,8 @@ export default class HelloWorldScene extends Phaser.Scene { private nextScene?: Phaser.GameObjects.Text; //reset private resetText: Phaser.GameObjects.Text | undefined; + //menuText + private menuText: Phaser.GameObjects.Text | undefined; constructor() { super('HelloWorldScene') @@ -223,6 +227,18 @@ export default class HelloWorldScene extends Phaser.Scene { this.resetText.on('pointerdown', () => { this.scene.restart(); }); + + // back to main + this.menuText = this.add.text(40, 10, 'Menu', { fontFamily: 'Arial', fontSize: '32', color: '#ffffff' }); + // menu Text touchable + this.menuText.setInteractive(); + // menuText + this.menuText.on('pointerdown', () => { + this.scene.start('BaseScene'); + }); + + + } //Handle buttons diff --git a/src/Scenes/LevelTwo.ts b/src/Scenes/LevelTwo.ts index aeaf6d3..6a582d6 100644 --- a/src/Scenes/LevelTwo.ts +++ b/src/Scenes/LevelTwo.ts @@ -5,6 +5,8 @@ import Button from '../Objects/Button'; import Player from '../Objects/Player'; //import Player from "./Objects/Player"; +import { TextButtonObject } from "../Objects/TextButtonObject"; + export default class LevelTwo extends Phaser.Scene { //Sprite creation @@ -23,6 +25,8 @@ export default class LevelTwo extends Phaser.Scene { private nextScene?: Phaser.GameObjects.Text; //reset private resetText: Phaser.GameObjects.Text | undefined; + //menuText + private menuText: Phaser.GameObjects.Text | undefined; constructor() { super('LevelTwo') @@ -230,12 +234,15 @@ export default class LevelTwo extends Phaser.Scene { this.physics.add.collider(this.buttons, this.platforms) this.physics.add.overlap(this.player1, this.buttons, this.handleHitButton, undefined, this) this.physics.add.overlap(this.player2, this.buttons, this.handleHitButton, undefined, this) - // reset touchable - this.resetText.setInteractive(); - // monitor reset - this.resetText.on('pointerdown', () => { - this.scene.restart(); - }); + + // back to main + this.menuText = this.add.text(40, 10, 'Menu', { fontFamily: 'Arial', fontSize: '32', color: '#ffffff' }); + // menu Text touchable + this.menuText.setInteractive(); + // menuText + this.menuText.on('pointerdown', () => { + this.scene.start('BaseScene'); + }); } //Handle buttons @@ -262,10 +269,12 @@ export default class LevelTwo extends Phaser.Scene { return; } + // sence transition private handleLoadNextScene() { this.scene.start('EndScene') } + //ThreeScene //private handleLoadNextScene(player1: Phaser.GameObjects.GameObject, sA: Phaser.GameObjects.GameObject) { //this.scene.start('ThreeScene')