/** Utilizes a tween to animate the target object over a certain time. Internally, this * method uses a tween instance (taken from an object pool) that is added to the * juggler right away. This method provides a convenient alternative for creating * and adding a tween manually. * * <p>Fill 'properties' with key-value pairs that describe both the * tween and the animation target. Here is an example:</p> * * <pre> * juggler.tween(object, 2.0, { * transition: Transitions.EASE_IN_OUT, * delay: 20, // -> tween.delay = 20 * x: 50 // -> tween.animate("x", 50) * }); * </pre> */ public void tween(object target, float time, TweenParams properties) { Tween tween = Tween.fromPool(target, time); foreach (var prop in properties) { if (hasProperty(tween, prop.Key)) { SetValue(tween, prop.Key, prop.Value); } else if (hasProperty(target, prop.Key)) { tween.animate(prop.Key, (float)prop.Value); } else { throw new ArgumentError("Invalid property: " + prop.Key); } } tween.addEventListener(starling.events.Event.REMOVE_FROM_JUGGLER, onPooledTweenComplete); add(tween); }