/** 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); }
private void onStartButtonTriggered( CEvent e ) { mStartButton.enabled = false; resetEgg(); // get next transition style from array and enqueue it at the end var transition = mTransitions[0]; mTransitions.RemoveAt(0); mTransitions.Add(transition); // to animate any numeric property of an arbitrary object (not just display objects!), // you can create a 'Tween'. One tween object animates one target for a certain time, // a with certain transition function. var tween = new Tween(mEgg, 2.0f, transition); // you can animate any property as long as it's numeric (int, uint, Number). // it is animated from it's current value to a target value. tween.animate("rotation", 90f); // conventional 'animate' call tween.moveTo(600f, 720f); // convenience method for animating 'x' and 'y' tween.scaleTo(0.5f); // convenience method for 'scaleX' and 'scaleY' tween.onComplete = new callbackDelegate(resetStartBtn); // the tween alone is useless -- for an animation to be carried out, it has to be // advance once in every frame. // This is done by the 'Juggler'. It receives the tween and will carry it out. // We use the default juggler here, but you can create your own jugglers, as well. // That way, you can group animations into logical parts. Starling.juggler.add(tween); // show which tweening function is used mTransitionLabel.text = transition; mTransitionLabel.alpha = 1.0f; var hideTween = new Tween(mTransitionLabel, 2.0f, Transitions.EASE_IN); hideTween.animate("alpha", 0.0f); Starling.juggler.add(hideTween); /* Starling.juggler.tween(mEgg, 2.0f, new TweenParams(){ {"delay",2.0f},{"x",600f},{"y",720f},{"scaleX",0.5f},{"scaleY",0.5f} }); */ }
public void moveTween2(float tweenTime, float xPos, float yPos, float zoom=1, bool round=false) { _cameraMoveTween = new Tween(_world, tweenTime); _cameraMoveTween.animate("x", -xPos); _cameraMoveTween.animate("y", -yPos); _cameraMoveTween.transition = Transitions.EASE_OUT; _cameraMoveTween.onComplete = Tween.Call(tweenComplete); _cameraMoveTween.roundToInt = round; _cameraZoomTween = new Tween(_harness, tweenTime); _cameraZoomTween.animate("scaleX", zoom); _cameraZoomTween.animate("scaleY", zoom); _cameraZoomTween.transition = Transitions.EASE_OUT; _cameraZoomTween.roundToInt = false; _juggler.add(_cameraMoveTween); _juggler.add(_cameraZoomTween); }