miaoda-game-vision-phaser
v0.3.0
Published
Phaser Graphics visibility polygon renderer for miaoda-game-vision2d-core.
Downloads
488
Readme
miaoda-game-vision-phaser
Use this Phaser 4 adapter to draw miaoda-game-vision2d-core visibility polygons or cones into a Phaser Graphics object and query LOS/FOV against the same obstacle set.
Install and use
pnpm add miaoda-game-vision2d-core miaoda-game-vision-phaser phaserconst vision = new VisionLayer(graphics, {
fillColor: 0xfff0b4,
fillAlpha: 0.35,
});
vision.obstacles.addBounds({ minX: 0, minY: 0, maxX: 960, maxY: 640 });
vision.renderCone(guardPos, facingDeg, 70, 400);
if (vision.inView(guardPos, facingDeg, 70, playerPos, 400)) raiseAlarm();The layer owns the supplied Graphics object. destroy() releases it and is terminal for style, clear, and rendering; obstacle-backed queries remain readable afterward. Rendering is explicit and should run when your game updates the viewer position.
