Yoyo tween: detecting the middle of the way?

Hey fellows,

I am returning to Phaser 3 after a little while and am working on a small project. I think my question is silly but here we go.

I have this simple yoyo and I’d like to know if there is an event that detects when it is exactly in the middle of the tween, that is, when it gets to the maximum position and will start to bounce back. I hope it makes sense… Thanks!

addglove = () => {
    this.glove = this.add.image(100, -300, 'glove');

    this.glovetween = this.tweens.add({
        onComplete: () => {
            IsGlove = false;
            this.glove.destroy();
            this.glovetween.remove();
        },
        targets: [this.glove],
        y: 140,
        ease: 'linear',
        duration: 500,
        yoyo:true,
        repeat: 0,
        callbackScope: this
    });
}

Instead to use the yoyo option I thought of doing a simple linear tween and at the OnComplete event create another tween to bounce it back, but I think that it would be to do thing the hard way…

I think you can use the onYoyo callback.

1 Like

Thank you Samme! It totally did the trick! :heart_eyes: