I have created a minimal example to reproduce:
var config = {
type: Phaser.AUTO,
width: 400,
height: 200,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
var textBox;
function preload() {
}
function create() {
textBox = this.add.text(200, 0, "text", {fill: "white"});
drawBox(this, [ 0,0, 99,0, 99,99, 0,99 ], 0xFF0000, 'red');
drawBox(this, [ 100,0, 199,0, 199,99, 100,99 ], 0x00FF00, 'green');
}
function drawBox(scene, points, color, msg) {
var polygon = scene.add.polygon(0, 0, points, color).setOrigin(0, 0);
polygon.setInteractive();
polygon.addListener(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN, function() {
textBox.setText(msg);
});
}
function update() {
}
When the green rectangle is hit, nothing happens; when the red rectangle is hit, the text turns green. Is this behaviour expected? If so, why? Or did I found a bug?
And on a side note: why is there a gap between the red and the green rectangle?
Tested with Phaser 3.16.2