/** * Modifies the delays of every tween in the group in order to sequence * them one after the other. * @return The group, for instruction chaining. */ public TweenGroup Sequence() { for (int i = 1; i < Tweens.Count; i++) { Tween tween = Tweens[i]; Tween previousTween = Tweens[i - 1]; tween.Delay(previousTween.GetDuration() + previousTween.GetDelay()); } return(this); }
// ------------------------------------------------------------------------- // Private methods // ------------------------------------------------------------------------- private int ComputeDuration() { int duration = 0; for (int i = 0; i < Tweens.Count; i++) { Tween tween = Tweens[i]; duration = Math.Max(duration, tween.GetDelay() + tween.GetDuration()); } return(duration); }
/** * Repeats the tween group for a given number of times. For infinity * repeats,use Tween.INFINITY. * @param count The number of repetitions. * @param delayMillis A delay, in milliseconds, before every repetition. * @return The group, for instruction chaining. */ public TweenGroup Repeat(int count, int delayMillis) { int totalDuration = ComputeDuration(); for (int i = 0; i < Tweens.Count; i++) { Tween tween = Tweens[i]; int delay = totalDuration + delayMillis - (tween.GetDuration() + tween.GetDelay()); tween.Repeat(count, delay); } return(this); }