Now you can tween multiple variables/parameters using a single tween object!
I added a class called MotionParameter to Motionlib which can be used with in the Tween class to tween multiple parameters using a single tween! And can also use either variable names (which can either be in object or outside of an object) or "tween name" as parameters!
for example before tween multiple variables/values together, say x, y and z, you would have to make 3 separate tween objects and add them to a TweenG
roup object. so you'd have to do
Code:
Tween x = new Tween(this, "x", 0, width, 100);
Tween y = new Tween(this, "y", 0, width, 100);
Tween z = new Tween(this, "z", 0, width, 100);
TweenGroup xyz = new TweenGroup(this, new Tween[]{x, y, z});
xyz.play();
then to get the tween positions for x, y, and z you'd have to do
Code:
xyz.getTween("x").getPosition();
xyz.getTween("y").getPosition();
xyz.getTween("z").getPosition();
or
Code:
x.getPosition();
y.getPosition();
z.getPosition();
depending on the scope of the x, y and z Tween objects.
but now using TweenParameter objects to tween using VALUES (w/o pre-defined variables) you can do
Code:
xyz = new Tween(this, "xyz");
xyz.addParameter(new MotionParameter("x", 0, 100));
xyz.addParameter(new MotionParameter("y", 0, 100));
xyz.addParameter(new MotionParameter("z", 0, 100));
xyz.setDuration(100);
xyz.play();
or
Code:
xyz = new Tween("xyz", "x:100, y:100, z:100", 100);
xyz.play()
or to tween using VARIABLES you can either do
Code:
float x, y, z;
x = y = z = 0;
xyz = new Tween(this, "xyz", "x:100, y:100, z:100", 100);
xyz.play()
or
Code:
float x, y, z;
x = y = z = 0;
xyz.addParameter(new MotionParameter(this, "x", 0, 100));
xyz.addParameter(new MotionParameter(this, "y", 0, 100));
xyz.addParameter(new MotionParameter(this, "z", 0, 100));
xyz.setDuration(100);
xyz.play();
then to get each tween position inside xyz write
Code:
t.getPosition("x");
t.getPosition("y");
t.getPosition("z");
or you can write
Code:
translate(x,y,z);
NOTE: "this" can be replaced by the any custom objects you make so you can tween variables with in custom objects too!
Also i know the addParameter is doing much more than the "variablename:value" way you can do much more using them. Too see more you can look at the different constructors for the Tween and MotionParameter class.
Also I fixed the delay and reverse bugs were fixed too!
The two newest examples Tween_Parameter_Test and TweenSequence_3DPath_Complex show how TweenParameters can be used.
I couldn't export all the examples so you'll have to run them yourself until i can resolve some GStreamer problems on OSX Leopard which are causing Processing IDE throw errors at runtime...
You can download the new release at
http://ekeneijeoma.com/processing/motionlib/Let me know your thoughts!