callback onStart in Tween work 1 time?

Hello. I need a help. I have a simple tween animation.

 this.wrongElementTween = this.scene.add.tween({
      paused: true,
      targets: [this.vellumWrong],
      alpha: 0.7,
      yoyo: true,
      repeat: 1,
      duration: 300,
      onStart:() => {
        console.log('Tween Start')
      },

      onComplete: () => {
        this.vellumWrong.setAlpha(0);
      },
    });

When you click on an element, start this tween: it flashes several times and the tween ends. When you first click on the element, callback onStart works normally. However, when repeated clicks on the same element onStart are no longer triggered. At the same time, others callbacks, onRepeat, onComplete are triggered without problem. It’s a bug, or do I misunderstand the mechanism of operation?

:wave:

How and when are you unpausing the tween?

I have an addListener placed on the element. When clicked, tween is launched. Like this:

> element.addListener('pointerdown', () => {
> this.wrongElementTween.play();
> })

That is all. The first click is triggered in full, including OnStart. On the following ones, OnStart does not work. Paused property is set, because I create a tween immediately at the moment of class initiation, and then launch it at the right moment

Re. play():

If the Tween is already playing, calling this method again will have no effect. If you wish to restart the Tween, use Tween.restart instead.

1 Like

My tween fires once with no repeats (one flash and end). Therefore, restart() is not suitable, since tween is no longer active. play() starts it again, the flash is triggered, then the onComplete callback. But OnStart does not start again, which I do not like. The only option that I have found so far is to create a new tween each time you click, first using remove() on the old one.

Use the onActive callback.