Game Development Community

Dynamic behavior creation

by Austin Reynolds · in Torque Game Builder · 10/05/2008 (11:54 am) · 4 replies

Does anyone know of a tutorial / resource or can show me how to do the following.

Here is what I have

new t2dStaticSprite() {
scenegraph = $sceneGraph;
class = rPlayer;
name = "joe";
Layer=1;
imageMap = eelsheetImageMap;
size = "5.00 3.00";
position = "1.00 1.00";
};

Which works great.

The problem is I need to add a behavior to the object. I have searched all over the forums on adding behaviors and dynamic behaviors but nothing that I can find shows how to either add the behavior(with attributes) into lets say a data block or to the object after its created.

Any help would be awesome!

Thanks for all those that have helped befor.

#1
10/05/2008 (12:11 pm)
You can add behaviors like this:

_behavior0 = "NameOfTheBehavior Field1 Value1 ... FieldN ValueN";
_behavior1 = "NameOfTheBehavior Field1 Value1 ... FieldN ValueN";
.
.
.

Everything between the quotes needs to be TAB separated.
#2
10/05/2008 (1:59 pm)
So just to make sure( I am going to try it here in a bit getting ready to take off) but I put that inside the

new t2dStaticSprite() {

or inside a data block.
#3
10/05/2008 (2:17 pm)
Yeah inside the braces, look at your .t2d level file and find an object that you added a behavior too via the editor. It looks just like he posted.


Another way is to do this.

%obj = new t2dStaticSprite()
{
...
};

%beh = BehaviorTemplatename.createInstance();
%beh.fields = what you want;
...

%obj.addBehavior( %beh );
#4
10/05/2008 (2:19 pm)
Ok Ill give that a try, thanks alot



I think im on your favorite list....Or your a stalker ;)