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!)
#42
I am thinking about moving these changes to a new resource, with your consent Charlie ofc! And creating a library of various sample effects as well! This could also be a good base for the Torque tutorial and resource website i had in mind!
05/12/2012 (1:00 pm)
Well you are welcome Tim!I am thinking about moving these changes to a new resource, with your consent Charlie ofc! And creating a library of various sample effects as well! This could also be a good base for the Torque tutorial and resource website i had in mind!
#43
As for forking Twillex, I've opened it up and you have my blessing to do with it what you want!
In my opinion, unless you are going a totally different route, it would make more sense for us to work together. This could be a 3d effects folder of examples. It could also be your updates to Twillex itself.
I noticed that you went from a call() to eval() at one point. I'd like to look into options because eval is much slower by nature. Perhaps there is a way to use an if/then that only uses eval() when necessary.
In any case, today I can't look at it, but soon I will.
Keep up the good work!
05/12/2012 (2:15 pm)
Hi @Lukas, congrats on this cool effect!As for forking Twillex, I've opened it up and you have my blessing to do with it what you want!
In my opinion, unless you are going a totally different route, it would make more sense for us to work together. This could be a 3d effects folder of examples. It could also be your updates to Twillex itself.
I noticed that you went from a call() to eval() at one point. I'd like to look into options because eval is much slower by nature. Perhaps there is a way to use an if/then that only uses eval() when necessary.
In any case, today I can't look at it, but soon I will.
Keep up the good work!
#44
Besides, i have no way to develop or test any changes in T2D.
I would wish i had a license tho, i got kindda curious about integrating full screen shaders in T2D seems like a fun project.
Owell back OT, i did use eval most of the places. I just couldn't find sufficient documentation on the call() method. One place i did change it was in the onCompleted event, because call is only locally scoped (i believe) so it had to be eval to make it able to call the $p2.play() with a call function it couldn't find those functions.
Anywhere besides that place i am not sure at all on whether an eval is necessary :)
Edit:
Did some changes to the source of the particleEmitter, made some goodies with it gonna upload it soon :)
Also brings me one step closer to the swirling particles! Will update with a proof of concept when i get it working!
Edit edit: The changes that i wanted to move into a new resource is because i would like to extend my resource: "Basic spell casting system" and add a new resource "Advanced spell casting system" and since i am unable to update the twillex code i would have to write the changes into a new resource unless you would give me access to the Twillex home page or add the changes yourself :D
05/12/2012 (2:26 pm)
Of course i will work together with you!Besides, i have no way to develop or test any changes in T2D.
I would wish i had a license tho, i got kindda curious about integrating full screen shaders in T2D seems like a fun project.
Owell back OT, i did use eval most of the places. I just couldn't find sufficient documentation on the call() method. One place i did change it was in the onCompleted event, because call is only locally scoped (i believe) so it had to be eval to make it able to call the $p2.play() with a call function it couldn't find those functions.
Anywhere besides that place i am not sure at all on whether an eval is necessary :)
Edit:
Did some changes to the source of the particleEmitter, made some goodies with it gonna upload it soon :)
Also brings me one step closer to the swirling particles! Will update with a proof of concept when i get it working!
Edit edit: The changes that i wanted to move into a new resource is because i would like to extend my resource: "Basic spell casting system" and add a new resource "Advanced spell casting system" and since i am unable to update the twillex code i would have to write the changes into a new resource unless you would give me access to the Twillex home page or add the changes yourself :D
#45
Sounds great! I'm out of town in about two days. Before then I'll try to figure the source control on sourceforge. I'll let you do what you want with the 3d examples, and I'll "code review" changes on the main code. Sounds like no problem.
As for call versus eval, I know you can run call on a non-class function, or a class method. You either do a "call(myfunc)" or "object.call(mymethod)". Both work. There may indeed be some problems with some types of globals or something. I'll look at it as soon as I can.
The problem with eval is that it literally has to compile the string that is sent to eval and then run it. this happens every single call! much, much slower. so I'm going to try to avoid it as long as humanly possible. :)
OK. Cool! Should be fun!
05/14/2012 (1:45 pm)
Hi @Lukas.Sounds great! I'm out of town in about two days. Before then I'll try to figure the source control on sourceforge. I'll let you do what you want with the 3d examples, and I'll "code review" changes on the main code. Sounds like no problem.
As for call versus eval, I know you can run call on a non-class function, or a class method. You either do a "call(myfunc)" or "object.call(mymethod)". Both work. There may indeed be some problems with some types of globals or something. I'll look at it as soon as I can.
The problem with eval is that it literally has to compile the string that is sent to eval and then run it. this happens every single call! much, much slower. so I'm going to try to avoid it as long as humanly possible. :)
OK. Cool! Should be fun!
#46
The only place i think it is necessary is in the onComplete tbh.
The place i read that it is locally scoped is in The Game Programmers Guide to Torque, but i think it was one of the issues i struggled with too :)
But it shouldn't hurt calling eval in onComplete as it isn't called as often! Btw posted a blog about this project to raise some interest about Twillex as i think it is one of the best resources i have played with!
05/14/2012 (1:55 pm)
I will clean the twillex code of eval methods then!The only place i think it is necessary is in the onComplete tbh.
The place i read that it is locally scoped is in The Game Programmers Guide to Torque, but i think it was one of the issues i struggled with too :)
But it shouldn't hurt calling eval in onComplete as it isn't called as often! Btw posted a blog about this project to raise some interest about Twillex as i think it is one of the best resources i have played with!
#47
Why don't we take it off-line for now so as not to fill up this comment section? You can find me at "my first name and my last initial @ hard-code.com"
In the meanwhile, keep up the good work and Tween on! :)
05/15/2012 (11:19 am)
Hi Lukas. I got a chance to read through the code changes using your "report" format. Looks promising! although I'd like to play with it an propose a few changes. I can't figure out how to download the new script using that report thingy, though.Why don't we take it off-line for now so as not to fill up this comment section? You can find me at "my first name and my last initial @ hard-code.com"
In the meanwhile, keep up the good work and Tween on! :)
#48
My email support*at*clan-net[.]dk
05/15/2012 (2:11 pm)
@Charlie, sent you a message! Tell me if you recieved it!My email support*at*clan-net[.]dk
#50
https://sourceforge.net/p/twillex
New features:
* you can now tween global variables
* tested with T3D
* you can eval() a string when a Tween completes. Useful for chaining or deleting quickly.
05/25/2012 (6:44 pm)
Just updated the Twillex code with Lukas' feature updates. Stay tuned for another copy with his 3D demos!https://sourceforge.net/p/twillex
New features:
* you can now tween global variables
* tested with T3D
* you can eval() a string when a Tween completes. Useful for chaining or deleting quickly.
#51
06/04/2012 (6:51 am)
This is a great resource, Charlie! I've been wanting to implement something like this for a while but it kept being pushed back. I dropped in the Twillex.cs and was able to use it immediately. I've extended my game update a few extra days just to spend time to work in this resource. It's made all the difference in the world to my previously boring and static UI. Awesome!
#52
You are working on an iPhone game right? So your results may be the first direct proof that Twillex works just fine in iT2D. I don't know why it wouldn't but...
Keep us informed!
06/04/2012 (10:47 am)
@Noby, that's great!You are working on an iPhone game right? So your results may be the first direct proof that Twillex works just fine in iT2D. I don't know why it wouldn't but...
Keep us informed!
#53
11/09/2013 (8:11 pm)
Just implemented Twillex in vlrtt. I'm very satisfied with it! The API is really nice and easy to use. Took me about five minutes to figure out the changes I needed to make and have a UI element sliding on and off screen. Though is anyone else using this in T3D? It seems a little jerky even though my game is running at 100fps. 
Torque 3D Owner Tim Scheiman
Ghost Ship Studios
That right there... is brilliant.
Thanks for posting it!