You can still access sprite
in the callback function, as long as you don’t name a callback argument the same thing.
sprite.menuText = [];
sprite.menuText.push(
this.add.text(this.gameWidth / 6, (this.gameHeight / 6) * 4, 'Attack')
.setInteractive()
.on('pointerdown', function () {
console.log('The sprite is', sprite);
})
);