Tween API improvements
Tween methods currently all return void and require to write lots of code for simple things.
That's a big missed opportunity to allow chaining for cheap by just returning the tween instance, so your Tween example could look like:
new Tween(object, 2.0, Transitions.EASE_IN_OUT) .animate("x", object.x + 50) .animate("rotation", deg2rad(45)) .fadeTo(0) // equivalent to 'animate("alpha", 0)' .run(); // equivalent to Starling.juggler.add(tween);
Add a static helper and you have an all modern API: Tween.select(object, 2.0, Transitions.EASE_IN_OUT).fadeTo(1).run();
Ha, Philippe, that's a great idea! Indeed, that would make it easy to initiate tweens in a very elegant way. Perfect! Thanks for the suggestion -- that's what I call constructive feedback! =)
I'll add that to Starling soon.
Daniel
Also .onComplete/.onCompleteArgs could be gathered as a chainable .complete(handler, args) ;)
Building on the shortcut methods like fadeTo that return this instance, another suggestion is the ability to chain separate Tweens would be to add a then() function:
then(duration:Number, delay:Number=0, transition:String=""):Tween
then() returns a new Tween object that will get run after this Tween Object's completion (plus an optional delay). So you can quickly chain multiple Tweens in a row:
obj.scaleX = obj.scaleY = obj.alpha = 0;
new Tween(obj, 0.5).fadeTo(1).scale(1).then(0.5, 0.25).scale(2).then(0.5, 0.25).fadeTo(0).scale(0).run();
Which, in english, means "grow and fade in for the first 500ms, then pause 250 ms, then grow to 2x, then pause 250ms, then fade out the last 500 ms"
The run() call would need to be marshaled to the front of the Tween stack, but that should be easy enough.
Of course, it's easy enough to extend Tween to do exactly this, or maybe I'll submit a pull request. =)
If the API is equal to the TweenJS (http://www.createjs.com/#!/TweenJS), we can use the export of toolkit for CreateJS (http://www.adobe.com/br/products/flash/flash-to-html5.html). This can be a plugin for starling.