Menu

Setup

Charles Patterson

To create a Twillex engine and Tweens requires set up, tear down, and frame updates.

Setup

Setup and tear-down work as usual in Torque. First, include the Twillex.cs script. (Twillex is written as a single script file.)

exec("<your_path>/Twillex.cs");

 

Then, create a Twillex engine to run your tweens. For instance

Twillex::create(myTweenEngine);

 

Where myTweenEngine can be any unique name you prefer. You could even make several engines if you wanted to keep categories of tweens separate.

Frame Updates

In Torque2D, it's not possible to get Torque to call an onUpdate() on Twillex objects each frame. (That only works for scene objects and Twillex is not one.) The scene graph will have to be kind and call Twillex::onUpdate(). For example:

function mySceneGraph::onUpdateSceneTick(%this) {
    // do all the other stuff also
    myTweenEngine.onUpdate();
}

 

Note that you don't have to call onUpdate() on the individual Tweens, just the Twillex engines.

In Torque3D, there is no scene graph update method. Instead call

    myTweenEngine.startUpdates();

 

This will cause updates every 1/30th of a second. If you prefer slower updates, you can pass in a parameter that specifies milliseconds between updates, such as 60 or 120.

Note that Torque2D users can also use startUpdates() but this author prefers the first method.

Use

Example Use is a page with several examples of creating and using Tweens.

Teardown

In the end, delete your Twillex objects as usual:

myTweenEngine.delete();

 


Related

Wiki: Tween Creation

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.