diff --git a/src/main.ts b/src/main.ts index 6e745e8..bcf35fd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,13 +11,13 @@ import ShittyShooterScene from '@/phaser/scenes/minigame/shitty-shooter-scene'; import ClickerRaceScene from "@/phaser/scenes/minigame/clicker-race-scene"; import { SETTINGS } from './settings'; -import {OddOneOutScene} from "@/phaser/scenes/minigame/oddOneOut-scene.ts"; import WaterDropScene from './phaser/scenes/minigame/water-drop-scene'; import * as THREE from 'three'; //import * as WebGLDebugUtils from './webgl-debug.js'; import DebugScene from './phaser/scenes/debug-scene.js'; +import { OddOneOutScene } from './phaser/scenes/minigame/odd-one-out-scene.js'; window.onload = () => { setTimeout(async () => { diff --git a/src/phaser/components/minigame/oddOneAsset.ts b/src/phaser/components/minigame/odd-one-asset.ts similarity index 74% rename from src/phaser/components/minigame/oddOneAsset.ts rename to src/phaser/components/minigame/odd-one-asset.ts index 8525ee3..a8b6ddb 100644 --- a/src/phaser/components/minigame/oddOneAsset.ts +++ b/src/phaser/components/minigame/odd-one-asset.ts @@ -6,10 +6,9 @@ import {Player} from "@/types"; const SIZE = 60; -export class oddOneAsset extends Phaser.GameObjects.Container { +export class OddOneAsset extends Phaser.GameObjects.Container { static SIZE = SIZE; - private graphics: Phaser.GameObjects.Graphics; // private image: Phaser.GameObjects.Image; @@ -26,19 +25,12 @@ export class oddOneAsset extends Phaser.GameObjects.Container { } constructor(scene: Phaser.Scene, id: number, x: number, y: number, isOdd: boolean = false) { - super(scene, x, y); + super(scene, x + SIZE * 0.5, y + SIZE * 0.5); this.setSize(SIZE, SIZE); this.isOdd = isOdd; this.id = id.toString(); - this.setInteractive({ - hitArea: new Phaser.Geom.Circle(0, 0, SIZE / 2), - hitAreaCallback: Phaser.Geom.Circle.Contains, - useHandCursor: false, - draggable: true - }, Phaser.Geom.Circle.Contains); - //this.scene.input.on(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN, this.onClicked.bind(this)); - + //this.scene.input.on(Phaser.Input.Events.POINTER_DOWN, this.onClicked.bind(this)); //this.image = new Phaser.GameObjects.Image(scene, 0, 0, 'chubbyRacer'); //this.image.setScale(SIZE / this.image.width); @@ -49,7 +41,7 @@ export class oddOneAsset extends Phaser.GameObjects.Container { this.graphics.fillStyle(0x00FF00); } - this.graphics.fillCircle(0, 0, (SIZE / 2)); + this.graphics.fillCircle(-SIZE / 2, -SIZE /2, SIZE / 2); //this.add(this.image); diff --git a/src/phaser/scenes/minigame/oddOneOut-scene-controller.ts b/src/phaser/scenes/minigame/odd-one-out-scene-controller.ts similarity index 90% rename from src/phaser/scenes/minigame/oddOneOut-scene-controller.ts rename to src/phaser/scenes/minigame/odd-one-out-scene-controller.ts index 2606cc9..288aee4 100644 --- a/src/phaser/scenes/minigame/oddOneOut-scene-controller.ts +++ b/src/phaser/scenes/minigame/odd-one-out-scene-controller.ts @@ -1,8 +1,6 @@ import MinigameSceneController from "@/phaser/scenes/base/minigame-scene-controller.ts"; -import {OddOneOutScene} from "@/phaser/scenes/minigame/oddOneOut-scene.ts"; +import {OddOneOutScene} from "@/phaser/scenes/minigame/odd-one-out-scene"; import AzNopolyGame from "@/game.ts"; -import {oddOneAsset} from "@/phaser/components/minigame/oddOneAsset.ts"; -import {Player} from "@/types"; const MAX_GAME_TIME = 30000; export class OddOneOutSceneController extends MinigameSceneController { diff --git a/src/phaser/scenes/minigame/oddOneOut-scene.ts b/src/phaser/scenes/minigame/odd-one-out-scene.ts similarity index 68% rename from src/phaser/scenes/minigame/oddOneOut-scene.ts rename to src/phaser/scenes/minigame/odd-one-out-scene.ts index c71c53b..946ec44 100644 --- a/src/phaser/scenes/minigame/oddOneOut-scene.ts +++ b/src/phaser/scenes/minigame/odd-one-out-scene.ts @@ -3,8 +3,8 @@ import MinigameScene from "../base/minigame-scene"; import {FRAME_PADDING, PLAYER_COLORS} from "@/style"; import {SETTINGS} from "@/settings"; -import {oddOneAsset} from "@/phaser/components/minigame/oddOneAsset.ts"; -import {OddOneOutSceneController} from "@/phaser/scenes/minigame/oddOneOut-scene-controller.ts"; +import {OddOneAsset as OddOneAsset} from "@/phaser/components/minigame/odd-one-asset"; +import {OddOneOutSceneController} from "@/phaser/scenes/minigame/odd-one-out-scene-controller"; import AzNopolyPanel from "@/phaser/components/ui/panel.ts"; const WORLD_BOUNDS = (() => { @@ -14,7 +14,7 @@ const WORLD_BOUNDS = (() => { export class OddOneOutScene extends MinigameScene { - private oddOneAssets: oddOneAsset[] = []; + private oddOneAssets: OddOneAsset[] = []; private graphics!: Phaser.GameObjects.Graphics; private playerPoints: number[] = []; @@ -22,7 +22,7 @@ export class OddOneOutScene extends MinigameScene { preload() { super.preload(); - oddOneAsset.preload(this); + OddOneAsset.preload(this); } init() { @@ -42,12 +42,17 @@ export class OddOneOutScene extends MinigameScene { } initiateOddOne(id: number, x: number, y: number, isOdd: boolean) { - let oddOne = this.add.existing(new oddOneAsset(this, id, x, y, isOdd)); - oddOne.setInteractive() - oddOne.on(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN, () => this.onClicked(oddOne)); + let oddOne = this.add.existing(new OddOneAsset(this, id, x, y, isOdd)); + oddOne.setInteractive({ + hitArea: new Phaser.Geom.Circle(0, 0, OddOneAsset.SIZE / 2), + hitAreaCallback: Phaser.Geom.Circle.Contains, + }); + oddOne.on(Phaser.Input.Events.POINTER_DOWN, () => { + this.onClicked(oddOne) + }); } - onClicked(oddOne: oddOneAsset) { + onClicked(oddOne: OddOneAsset) { console.log("clicked" + oddOne.id); //oddOne.destroy(); }