Hi i’d like to add dynamically the tween event to an game object.
I’ve found the event called “tween chain” but once the chain event is completed, it doesn’t execute the last tween event that i added to the chain. (it means, i add the event after the chain event is finished)
So i’d like to know if there’s any method in tween chain event that enable “dynamically adding tween event and executing it even though it is finished”.
By the way, it is my code that enable the above.
if (this.topBarTween) {
if (!this.isTweenEnd) {
// if the whole event of chain is not finished, add the tween event to the chain.
const newTween = {
targets: this.status_bar,
width: `+=${max_width / curTarget}`,
duration: 200,
};
this.topBarTween.add(newTween);
} else {
// if the whole event of chain is finished, make new chain event.
this.isTweenEnd = false;
this.topBarTween = this.tweens.chain({
targets: this.status_bar,
tweens: [{width: `+=${max_width / curTarget}`, duration: 200}],
onComplete: () => {
this.isTweenEnd = true;
},
});
}
} else {
// if there isn't a tween chain event, make new one
this.topBarTween = this.tweens.chain({
targets: this.status_bar,
tweens: [{width: `+=${max_width / curTarget}`, duration: 200}],
onComplete: () => {
// if the whole event of chain is finished, set the variable that tracks the tween event process true.
this.isTweenEnd = true;
},
});
}