Using a grid of hexagons, I’m using setDepth()
to properly display them. Now, when I capture the pointerdown
event, I can figure out which hexagon is under the mouse. This of course, falls apart near the edges of the image as the getBounds
returns a rectangle.
When clicking on the edge of a hexagon, I get two images back with this code. Is there a relative easy way to do edge detection without setting pixelPerfect
true on a bunch of sprites?
this.input.on('pointerdown', function (pointer: Phaser.Input.Pointer) {
console.log(`x: ${pointer.worldX}, y: ${pointer.worldY}`);
var imgs = this.cells.filter((e: Assets.Cell,i,a)=> {
return e.img.getBounds().contains(pointer.worldX, pointer.worldY);
});
console.log(imgs);
}, this);
Optionally, is using pixelPerfect
on 60 to 300 background images going to impact performance enough for me to worry about it?