Hi! My name is daveo
I am writing a very simple Phaser tutorial and I cannot determine if I need to remove a tween after it completes to conserve memory. In my case, I will not need to re-use the tween after it completes… here is my code and I am making an assumption that the tween should be removed on completion:
whoseTurnIsIt() {
let x = this.game.config.width / 2;
let y = this.game.config.height / 2;
let t = this.whoseTurn = PLAYER_X ? "PLAYER X" : "PLAYER_Y";
let label = this.add.text(x, y, t,
{ fontSize: '32px Arial', fill: '#000' });
label.setOrigin(0.5, 0.5);
let tween = this.tweens.add({
targets: label,
alpha: 0,
ease: 'Power1',
duration: 2000,
onComplete: this.turnTweenComplete,
onCompleteParams: [label]
});
}
turnTweenComplete(tween, targets, params) {
tween.remove();
}
Thanks very much!