Actuate tween speed up on repeat

I’ve got a tween which I’m repeating a number of times… (using .repeat(N) )

This works fine, but what I’d really like is to make the tween get slightly quicker on each cycle…

Is there a way of updating the duration from within the the onRepeat ?

(I have tried doing it manually, resetting the position, and trying to re-run the tween, but it appears you can’t use a delay with apply:

Actuate.apply (sprite, {y:-100}).delay(d); //fails

I’ve also tried

Actuate.tween(sprite, 0, {y:-100 }, false).).delay(d); //fails

It is an interesting question to see if the delay is updateable once the tween starts? Hopefully someone clever will know the answer.

This is probably very ugly but it would achieve what you are trying to do.

var _delay:Float = 5;

animate();

private function animate() : Void
	{
		if(_delay > 0)
		{
			Actuate.tween(sprite, 1, {y:-100}).delay(_delay).onComplete(function():Void{
				_delay -= 1;
				animate();
			});
		}
	}

I think you can do it, but it would require messing with private variables. Starting a new tween each time would be easier:

private var tweenLength:Float;
private var startY:Float;

private function startAnimation():Void {
    tweenLength = 1;
    startY = sprite.y;
    
    repeatAnimation();
}

private function repeatAnimation():Void {
    if(tweenLength < 0.1) {
        return;
    }
    
    sprite.y = startY;
    Actuate.tween(sprite, tweenLength, {y:-100}).onComplete(repeatAnimation);
    
    tweenLength *= 0.9;
}

Thanks for both your suggestions… As I was only repeating a about 5 times, I just created a while{} loop within which I reduced the duration, and updated the delay accordingly.