Hello everybody, this is my first question and nice to be here.
I have drawn a circle in the middle of a scene, now I want to implement select/deselect functionality inside the Arc class itself.
export default class SimpleScene extends Phaser.Scene {
constructor() {
super();
}
create() {
this.add.existing(new TestCircle({scene: this}));
}
}
class TestCircle extends Phaser.GameObjects.Arc {
constructor(opts) {
super(opts.scene, 150, 150, 40, undefined, undefined, undefined, 0xFFFFFF);
this.setInteractive();
this.on(Phaser.Input.Events.POINTER_OVER, this.onPointerOver);
this.on(Phaser.Input.Events.POINTER_OUT, this.onPointerOut);
this.on(Phaser.Input.Events.POINTER_DOWN, this.onPointerDown);
opts.scene.input.on(Phaser.Input.Events.POINTER_DOWN, this.onPointerDownOut);
this.on(Phaser.Input.Events.POINTER_DOWN_OUTSIDE, () => console.log('NOT OK'));
}
onPointerOver() { console.log('onPointerOver'); }
onPointerOut() { console.log('onPointerOut'); }
onPointerDown(ptr, x, y, evt) { console.log('onPointerDown'); evt.stopPropagation(); }
onPointerDownOut() { console.log('onPointerDownOut'); }
}
Edit
One possible solution I came up with is to attach a “pointerdown” handler to the scene