Added completeAfterLoop method

This commit is contained in:
Richard Davey 2022-09-16 17:50:18 +01:00
parent 23bd9c744c
commit d42122d05b

View file

@ -459,6 +459,34 @@ var BaseTween = new Class({
return this; return this;
}, },
/**
* Flags the Tween as being complete only once the current loop has finished.
*
* This is a useful way to stop an infinitely looping tween once a complete cycle is over,
* rather than abruptly.
*
* If you don't have a loop then call `Tween.stop` instead.
*
* @method Phaser.Tweens.BaseTween#completeAfterLoop
* @fires Phaser.Tweens.Events#TWEEN_COMPLETE
* @since 3.60.0
*
* @param {number} [loops=0] - The number of loops that should finish before this tween completes. Zero means complete just the current loop.
*
* @return {this} This Tween instance.
*/
completeAfterLoop: function (loops)
{
if (loops === undefined) { loops = 0; }
if (this.loopCounter > loops)
{
this.loopCounter = loops;
}
return this;
},
/** /**
* Immediately removes this Tween from the TweenManager and all of its internal arrays, * Immediately removes this Tween from the TweenManager and all of its internal arrays,
* no matter what stage it is at. Then sets the tween state to `REMOVED`. * no matter what stage it is at. Then sets the tween state to `REMOVED`.