Thanks, its helped.
But a simple function gets too many lines of code:
onFlagClicked(pointer, flag) {
let x = flag.x - 2;
let y = flag.y - 2;
let width = flag.width + 4;
let height = flag.height + 4;
if (flag.value == 1 && flag.row == 0) {
this.r1 = this.add.rectangle(x, y, width, height).setOrigin(0);
this.r1.setStrokeStyle(3, 0x00D1FF);
sessionStorage.setItem('player-team', 1);
if (this.r2) this.r2.setStrokeStyle(0, 0x00D1FF);
if (this.r3) this.r3.setStrokeStyle(0, 0x00D1FF);
if (this.r4) this.r4.setStrokeStyle(0, 0x00D1FF);
} else if (flag.value == 2 && flag.row == 0) {
this.r2 = this.add.rectangle(x, y, width, height).setOrigin(0);
this.r2.setStrokeStyle(3, 0x00D1FF);
sessionStorage.setItem('player-team', 2);
if (this.r1) this.r1.setStrokeStyle(0, 0x00D1FF);
if (this.r3) this.r3.setStrokeStyle(0, 0x00D1FF);
if (this.r4) this.r4.setStrokeStyle(0, 0x00D1FF);
}
}
When i click on the rectangle - i check the value of that rectangle, and check created rectangles - if some rectangles is created - i add lineWidth 0.
Is this how it should be done or is there a better way?