duck-tween
duck-tween copied to clipboard
Better ways to add repeated animations
Problem
Quite often you want a sequence that contains a repeated portion of an animation.
There is no decent way to do this, you either loop and create multiple instance of identical animations, or create one and add it multiple times. You can use linq, but then the .Add
function only accepts params array, so requires a cast to an array,
Proposals
-
A new overload
AnimationCollection.Add(IEnumerable<TAnimation> animations)
where TAnimation : AbstractAnimation This would allow us to use linq. so we can do don't need to doToArray
. the type parameters are present so we don't need.Cast<AbsrtactAnimation>
- to surpress covariance warnings. -
Modify the original
Add(params AbstractAnimation[] animations)
to use type params for the same reason as above. -
A new overload
Add(AbstractAnimation animation, int amount)
so we can easily reuse the same instance multiple times over just using an integer -
ForEach(IEnumerable<T>, Func<T, AbstractAnimation> createAnimation)
so we can map elements in an array to a corresponding animation eg: given a list of transformsmyTransforms
sequence.ForEach(myTransforms, t => t.Move(from, to, duration, easing));