Twillex: Tweening for Torque
by Charlie Patterson · 01/25/2012 (11:54 pm) · 53 comments
Hi everyone! I thought I'd throw out my first resource to the community. I hope you like it. It's Twillex, a Tweening engine for Torque (2D and iTorque) written entirely in TorqueScript. Tweening is animating motion in more ways than just "linear." Give it a start and end point, and an "easing function" and it will make a pretty motion for you. You can tween positions, rotations, sizes, *colors*, alphas, your own variables...
Well here, see a video first (link).
And here is the Twillex home page on SourceForge where you can download the source and the test project used to make the movie (zipped up).
To make a Tween, you typically do a one-liner like so:
The entire Twillex engine is a single TorqueScript file, to make it easier to add to your project. There are docs in the source file, an example project, and a wiki you can add to. It probably works on most version of Torque and most releases.
I'm pretty proud of it. Let me know if you find it fun!
Twillex Home Page
P.S. Check the comments on this post for any updates.
(Also, if you enjoy this resource, please consider "paying forward" with a click on my game's like button, here: facebook.com/RednecksVsRobots. Gonna look for some funding soon and likes will help, I hope!)
Well here, see a video first (link).
And here is the Twillex home page on SourceForge where you can download the source and the test project used to make the movie (zipped up).
To make a Tween, you typically do a one-liner like so:
Tweener.to(1000, %this, "position:100 50, a:0.5", "ease:bounce_out flipflop:true");
The entire Twillex engine is a single TorqueScript file, to make it easier to add to your project. There are docs in the source file, an example project, and a wiki you can add to. It probably works on most version of Torque and most releases.
I'm pretty proud of it. Let me know if you find it fun!
Twillex Home Page
P.S. Check the comments on this post for any updates.
(Also, if you enjoy this resource, please consider "paying forward" with a click on my game's like button, here: facebook.com/RednecksVsRobots. Gonna look for some funding soon and likes will help, I hope!)
#2
@Frank
I cook a similar system for T2D and T3D here, soon published.
www.garagegames.com/community/blogs/view/21556
But it's not for iT2D.
01/26/2012 (4:57 am)
It's interesting.@Frank
I cook a similar system for T2D and T3D here, soon published.
www.garagegames.com/community/blogs/view/21556
But it's not for iT2D.
#3
There are some short-cut names for size, and rotation along one axis. Namely, x, y, sx, sy. You won't have a built in z, sz. However, those could be added in 4 minutes.
01/26/2012 (9:33 am)
Hi @Frank, I don't own T3D, but I'm 96% sure it will work fine with it. For T2D, you can give it a tweening ending position like as a string like "position:30 50". I believe that if you give it a position with a 3-element vector instead it will work fine.There are some short-cut names for size, and rotation along one axis. Namely, x, y, sx, sy. You won't have a built in z, sz. However, those could be added in 4 minutes.
#4
01/26/2012 (11:11 am)
Awesome resource Charlie! Looking forward to the weekend now so I can play with it.
#5
01/26/2012 (12:57 pm)
awesome! love it! thanks! you rock!
#6
Quick update: SourceForge, where I put this for safe-keeping, has been a bit confusing. I've re-arranged a bit today to simplify. I've also made a quick bug-fix which isn't a show-changer. You can use what you got or get a new one.
Once you follow the link to the Twillex home, click the "Files" tab and download "Twillex_Test". That should be the only file there to download now. If you want to copy Twillex.cs out of that project and into your own, it's inside the project.
01/27/2012 (1:36 pm)
Thanks @Scott and @Ben!Quick update: SourceForge, where I put this for safe-keeping, has been a bit confusing. I've re-arranged a bit today to simplify. I've also made a quick bug-fix which isn't a show-changer. You can use what you got or get a new one.
Once you follow the link to the Twillex home, click the "Files" tab and download "Twillex_Test". That should be the only file there to download now. If you want to copy Twillex.cs out of that project and into your own, it's inside the project.
#7
And I'm done!
01/27/2012 (1:48 pm)
A quick example of practical use.- I want an object to "fall into the world and bounce" on the ground before it starts attacking. This means I want to travel about 30 world units and ease in with a bounce tweener.
- What I know is where I want it to land. I can save time by setting it at its "end" and then tweening from somewhere, not to somewhere:
function ArchetypeBehavior::setWorldPosition(%this, %tile)
{
%this.owner.position = %this.getTilePosition(%tile);
Tweener.fromOnce(1000, %this.owner, "y:-30", "relative:true, ease:bounce_out");
}- I also want it to go from almost transparent (alpha of 0.2) to opaque on the way down.
- I want it to fade in faster than it falls so that it is fully substantial by the time it hits the ground. Because I want to use two different tweening rates, one for falling and one for fading in, I'm gonna need two tweens:
// ... same as before Tweener.fromOnce( 400, %this.owner, "a:0.2", "ease:quint_in");
And I'm done!
#8
01/27/2012 (8:20 pm)
This should be part of T2D...
#9
I was thinking for just GUIs in T3D. But holy yes it would be awesome for 3D objects as well! It would be great for walk-through tutorials for one! Thanks!
01/28/2012 (5:26 pm)
@Charlie,I was thinking for just GUIs in T3D. But holy yes it would be awesome for 3D objects as well! It would be great for walk-through tutorials for one! Thanks!
#10
01/30/2012 (12:29 pm)
Oh hells yeah! loving it! I'll never get any work done though too many new toys to play with!
#11
01/30/2012 (12:57 pm)
Very impressive Charlie - loved the end sequence of your video.
#12
01/30/2012 (4:29 pm)
This looks like it would work awesome for some stuff! Am I allowed to use this in a commercial project?
#13
It's basically BSD license which means do what you want, but please leave my name in the library file... a credit wouldn't hurt. ;^)
01/30/2012 (5:45 pm)
@Andrew, hell yeah! please use it in a commercial project!It's basically BSD license which means do what you want, but please leave my name in the library file... a credit wouldn't hurt. ;^)
#14
01/31/2012 (7:24 am)
@Charlie, Cool! Thanks, and I will be sure to credit you at the end.
#15
sourceforge.net/p/twillex/wiki/Home/
02/03/2012 (12:53 pm)
Quick update. For those looking for a little documentation, I spent a while creating some on sourceforge. How to create Tweens, use them, and examples and such.sourceforge.net/p/twillex/wiki/Home/
#16
02/09/2012 (9:57 am)
Ok, this looks awesome, Thanks for putting this up for us Charlie !
#17
Within an hour of even hearing about this, it was in use in my game.
It's so easy to use I'm confidently tweening things around in my game right now, even knowing that my producers are going to be expecting a new (and bug free) build tomorrow...
I hope there's no critical crash bugs! :) I'm not scared, really.
Also, your script is very nicely commented. That'll make it a breeze to modify and build on. Bonus points for using the word "twittling."
Good stuff, man. Thank you.
02/09/2012 (3:46 pm)
Twillex is awesome, and super easy to drop in and use.Within an hour of even hearing about this, it was in use in my game.
It's so easy to use I'm confidently tweening things around in my game right now, even knowing that my producers are going to be expecting a new (and bug free) build tomorrow...
I hope there's no critical crash bugs! :) I'm not scared, really.
Also, your script is very nicely commented. That'll make it a breeze to modify and build on. Bonus points for using the word "twittling."
Good stuff, man. Thank you.
#18
02/09/2012 (9:51 pm)
Wow, thanks @Tim! I swear I didn't pay him to say such nice things. ;^)
#19
02/12/2012 (12:25 pm)
Thanks for this awesome piece of code charlie! This will help many of us! :)
#20
02/12/2012 (12:32 pm)
Thanks @witcher! It was fun to stretch my "maths" for the first time in a while.
Torque Owner Demolishun
DemolishunConsulting Rocks!
Looks cool BTW!