Skip to content

Commit

Permalink
camera for spawn selection scene adn game scene fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
keshav2010 committed Apr 28, 2024
1 parent 2a35f8b commit 327286d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 7 additions & 2 deletions public/scenes/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 10 additions & 4 deletions public/scenes/SpawnSelectionScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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());

Expand All @@ -189,7 +195,7 @@ export class SpawnSelectionScene extends BaseScene {
controlConfig
);

this.AddSceneEvent(
this.AddInputEvent(
"wheel",
(
pointer: any,
Expand Down

0 comments on commit 327286d

Please sign in to comment.