monteiz
February 16, 2022, 1:41pm
1
After setting an onComplete
callback for a certain timeline, both stop
and destroy
timeline
's methods cause the onComplete callback to be called.
How can I avoid such a behaviour?
Should I manually remove the callback first, or there is a quicker way to achieve that?
samme
February 16, 2022, 4:02pm
2
I guess you have to remove them.
timeline.callbacks.onComplete = null;
1 Like
monteiz
February 16, 2022, 4:37pm
3
Yeah, I guess so.
At the end I have created a method:
cancelTimeline(timeline) {
if (!timeline) return;
Object.keys(timeline.callbacks).forEach((key) => {
timeline.callbacks[key] = null;
});
timeline.destroy();
}
It would be nice to have a cancel
method on the timeline
class itself.
Thanks Samme
samme
March 23, 2022, 4:11pm
4
It looks like you can do
timeline.destroy();
this.tweens.remove(timeline);
to avoid the onComplete callback.
1 Like
Thanks for that Samme. However I think it is best to stick with the “hardcore” solution, it appears to be more robust towards future framework updates.
samme
March 24, 2022, 4:04pm
6
Pretty sure remove()
will keep working.