I'm working on a game that mostly uses the mouse as a controller. It has the player using the mouse to click on in game buttons. One set of buttons are supposed to disappear after being clicked on once, but for some reason I can't get this to happen. Below is the code for one of those buttons, with it being the same for all the others of this type, except for variable names.
this.gardenChoice = this.add.image(430, 200, 'gardenButton').setInteractive();
this.gardenPrice = 100000000000;
this.gardenChoice.on('pointerdown', function (pointer) {
if (money >= this.gardenPrice){
money = money - this.gardenPrice;
this.garden = true;
this.gardenChoice.setAlpha(0);
this.bubble.setAlpha(0);
this.speech.setText('');
this.cost.setText('');
}
}, this);
The lines that deal with the gardenChoice image is where I suspect the trouble is. When adding the image to the scene, I had to put the setInteractive() on the end to make it work with the mouse, but I think its also making it impossible to use methods on it. I've tried the setAlpha() and destroy() methods, but neither had any effect.
I wish to know, is there a different method of some kind I can use to get the desired effect? I'm trying to have the button removed from the scene, or at least turn invisible, after it is clicked on.
If it helps, I'm using Phaser 3 in VSCode.