Update on Go3D API – much more simple
Well, thanks to the guys on the GoASAP list, I’ve started coming up with an API that most of us are used to seeing/using with packages like Tweener and Fuse. The change is that you literally create the propertyChanges array for Tween3D in the arguments to pass to the constructor. No parsing has to be done in the constructor at all – just set the propertyChanges array to what’s passed in the constructor.
So, what used to look like this:
var tween:Tween3D = new Tween3D(target, 1, Equations.easeOutCubic, .5);
tween.x = 0;
tween.y = 50;
tween.rotationZ = 0;
Now looks like this:
tween = new Tween3D(target, [Go3D.x(0), Go3D.y(50), Go3D.rotationZ(0)], 1, Equations.easeOutCubic, .5);
you can still create a Tween3D object and set the properties outside of the constructor if you want to of course.
The coolest part is that this abstracts the property objects. You can create 1 or multiple property classes that return property objects. So, in this sample, Go3D is a “properties class” that has static methods called x, y, z, rotationX, rotationY, rotationZ and they all return a Go3DProperty object that Tween3D uses. Now imagine that all of this is strongly typed, it’s fast and in a large scale development environment with many devs you could lock down what properties are tweenable as well as other logic and rules around doing this type of work. It’s complete abstracted out from the tweening/sequencing itself.
I’ve updated the rolodex files as well as put the new source out:
Same demo, new code 🙂
The new createTween method now looks like this:
protected function createTween():void
sequence = new SequenceCA();
sequence.addEventListener(GoEvent.COMPLETE, handleSequenceComplete, false, 0, true);
tween_0 = new Tween3D(target, [Go3D.x(0), Go3D.y(50), Go3D.rotationZ(0)], 1, Equations.easeOutCubic);
sequence.lastStep.advance = new OnDurationComplete(.2); // advance early/overlap
tween_0b = new Tween3D(target, [Go3D.z(200)], 1, Equations.easeOutCubic);
sequence.addStep(tween_0b, true); // 2nd param groups it with previous step. param is “addToLastStep”
tween_1 = new Tween3D(target, [Go3D.x(-10), Go3D.y(85), Go3D.rotationZ(15)], 1, Equations.easeOutCubic);
sequence.lastStep.advance = new OnDurationComplete(.25); // advance early/overlap
tween_2 = new Tween3D(target, [Go3D.rotationX(0), Go3D.rotationY(0)], 1, Equations.easeOutBounce);