2d sprite questions...
by Christopher Hernandez · in Torque Game Builder · 11/09/2006 (10:11 pm) · 4 replies
What exactly is the correct syntax to have another object from your library "spawned" into the level?
Also, how do I assign a datablock through code to this new object?
Thanking all in advance.
Also, how do I assign a datablock through code to this new object?
Thanking all in advance.
#2
This would copy all the settings from the sprite named "originalCopy" to the sprite named "spawnedCopy", and assigned the "myConfigDataBlock" to it --
11/10/2006 (6:48 am)
If your "spawning", I assume your sprite already exists in the level somewhere -- somewhere most likely off screen ... in this case, you could do something like Ben suggested, but slightly modified:%myNewObject new t2dStaticSprite(spawnedCopy: originalCopy)
{
config = "myConfigDataBlock";
};This would copy all the settings from the sprite named "originalCopy" to the sprite named "spawnedCopy", and assigned the "myConfigDataBlock" to it --
#3
11/10/2006 (9:56 am)
Cool guys, thank you for your respones. I'll give both of your suggestions a try.
#4
11/10/2006 (10:03 am)
You can also use the clone() command on the object you want to copy which will return the ID of the new object instance.
Torque Owner Ben R Vesco
%myNewObject = new t2dStaticSprite(aSprite) { scenegraph = t2dScene; config = "myConfigDatablock"; }