Change crosshair targeting sprite
This commit is contained in:
@@ -68,8 +68,7 @@ export class GameScene extends Phaser.Scene {
|
||||
this.dungeonRenderer = new DungeonRenderer(this);
|
||||
this.cameraController = new CameraController(this.cameras.main);
|
||||
this.itemManager = new ItemManager(this.world, this.entityManager);
|
||||
const targetingGraphics = this.add.graphics().setDepth(2000);
|
||||
this.targetingSystem = new TargetingSystem(targetingGraphics);
|
||||
this.targetingSystem = new TargetingSystem(this);
|
||||
|
||||
// Launch UI Scene
|
||||
this.scene.launch("GameUI");
|
||||
@@ -213,12 +212,16 @@ export class GameScene extends Phaser.Scene {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const { x: tx, y: ty } = this.getPointerTilePos(this.input.activePointer);
|
||||
|
||||
this.targetingSystem.startTargeting(
|
||||
item.id,
|
||||
player.pos,
|
||||
this.world,
|
||||
this.dungeonRenderer.seenArray,
|
||||
this.world.width
|
||||
this.world.width,
|
||||
{ x: tx, y: ty }
|
||||
);
|
||||
this.emitUIUpdate();
|
||||
return;
|
||||
@@ -242,12 +245,15 @@ export class GameScene extends Phaser.Scene {
|
||||
return;
|
||||
}
|
||||
|
||||
const { x: tx, y: ty } = this.getPointerTilePos(this.input.activePointer);
|
||||
|
||||
this.targetingSystem.startTargeting(
|
||||
item.id,
|
||||
player.pos,
|
||||
this.world,
|
||||
this.dungeonRenderer.seenArray,
|
||||
this.world.width
|
||||
this.world.width,
|
||||
{ x: tx, y: ty }
|
||||
);
|
||||
this.emitUIUpdate();
|
||||
}
|
||||
@@ -671,4 +677,12 @@ export class GameScene extends Phaser.Scene {
|
||||
}
|
||||
}
|
||||
|
||||
private getPointerTilePos(pointer: Phaser.Input.Pointer): { x: number, y: number } {
|
||||
const worldPoint = this.cameras.main.getWorldPoint(pointer.x, pointer.y);
|
||||
return {
|
||||
x: Math.floor(worldPoint.x / TILE_SIZE),
|
||||
y: Math.floor(worldPoint.y / TILE_SIZE)
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user