From 327286d5f16c9aa242ee651b8e24f5e063384b0d Mon Sep 17 00:00:00 2001 From: keshav2010 Date: Mon, 29 Apr 2024 02:15:42 +0530 Subject: [PATCH] camera for spawn selection scene adn game scene fixed --- public/scenes/GameScene.ts | 9 +++++++-- public/scenes/SpawnSelectionScene.ts | 14 ++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/public/scenes/GameScene.ts b/public/scenes/GameScene.ts index 8f8cd02..ad7d4d0 100644 --- a/public/scenes/GameScene.ts +++ b/public/scenes/GameScene.ts @@ -412,15 +412,20 @@ export class GameScene extends BaseScene { this.scene.launch(CONSTANT.SCENES.HUD_SCORE); this.cameras.main - .setBounds(0, 0, this.canvasWidth, this.canvasHeight) + .setBounds( + -this.canvasWidth / 2, + -this.canvasHeight / 2, + this.canvasWidth * 2, + this.canvasHeight * 2 + ) .setName("WorldCamera"); + this.cameras.main.setBackgroundColor("rgba(255,255,255,0.3)"); var mapGraphics = this.add.graphics(); mapGraphics.depth = -5; mapGraphics.fillStyle(0x000000, 1); mapGraphics.fillRect(0, 0, this.canvasWidth, this.canvasHeight); this.AddObject(mapGraphics); - cursors = this.input.keyboard?.createCursorKeys(); const controlConfig = { camera: this.cameras.main, diff --git a/public/scenes/SpawnSelectionScene.ts b/public/scenes/SpawnSelectionScene.ts index c64d9ee..cc8d580 100644 --- a/public/scenes/SpawnSelectionScene.ts +++ b/public/scenes/SpawnSelectionScene.ts @@ -38,11 +38,11 @@ export class SpawnSelectionScene extends BaseScene { networkManager = this.registry.get("networkManager") as NetworkManager; const map = this.make.tilemap({ - key: "map1" + key: "map1", }); const tileset = map.addTilesetImage("groundtiles", "img_groundtiles"); console.log(`tileset set `, tileset); - const layer = map.createLayer("groundlayer", tileset!, 0,0); + const layer = map.createLayer("groundlayer", tileset!); this.data.set("map1", map); networkManager.sendEventToServer( @@ -163,8 +163,14 @@ export class SpawnSelectionScene extends BaseScene { }); this.cameras.main - .setBounds(0, 0, this.canvasWidth, this.canvasHeight) + .setBounds( + -this.canvasWidth / 2, + -this.canvasHeight / 2, + this.canvasWidth * 2, + this.canvasHeight * 2 + ) .setName("WorldCamera"); + this.cameras.main.setBackgroundColor("rgba(255,255,255,0.3)"); var mapGraphics = this.AddObject(this.add.graphics()); @@ -189,7 +195,7 @@ export class SpawnSelectionScene extends BaseScene { controlConfig ); - this.AddSceneEvent( + this.AddInputEvent( "wheel", ( pointer: any,