Using the clone method of the t2dSceneObject
by Dennis Harrington · in Torque Game Builder · 06/04/2006 (1:41 pm) · 4 replies
I've been using the clone method for dynamically creating a ball that gets constantly deleted and respawned. It works great most of the time but occasionally I'll get the following error:
t2dSceneObject::loadStream() - Invalid Stream Header ID!
t2dSceneObject::clone() - Error loading Clone-stream!
Con::execute - 0 has no namespace: onRemove
This usually happens after 15-30 clone actions have occured, but sometimes I can clone well over 100 times or more without any problem.
Obviously, I need this to be consistent and predictable so I'm wondering if there's another method I should be using. I noticed that in some of the tutorials the process used to duplicate a sprite involves manually copying each and every property to a new sprite object. Is that the preferred method due to some issues with how clone works?
Any help or feedback would be greatly appreciated! :)
t2dSceneObject::loadStream() - Invalid Stream Header ID!
t2dSceneObject::clone() - Error loading Clone-stream!
Con::execute - 0 has no namespace: onRemove
This usually happens after 15-30 clone actions have occured, but sometimes I can clone well over 100 times or more without any problem.
Obviously, I need this to be consistent and predictable so I'm wondering if there's another method I should be using. I noticed that in some of the tutorials the process used to duplicate a sprite involves manually copying each and every property to a new sprite object. Is that the preferred method due to some issues with how clone works?
Any help or feedback would be greatly appreciated! :)
#2
I'll try this tonight. The only thing I find odd is that it should always be the same class as I'm using one object as a template for every clone action. I'll check it out and post more if it doesn't solve it.
06/07/2006 (6:35 pm)
Thanks for the response, Melv.I'll try this tonight. The only thing I find odd is that it should always be the same class as I'm using one object as a template for every clone action. I'll check it out and post more if it doesn't solve it.
#3
At any rate, I've decided to just use a function that will create a new sprite on demand with all the properties I need. It seems to be 100 percent reliable and that's probably more important.
06/10/2006 (12:45 pm)
I was able to confirm that both objects were the same type. It appears that clone was just randomly breaking for some reason. I noticed there was a note that something in the clone function was tweaked with RC2 but I haven't used it yet since I'm pretty deep at the moment and don't want to port my game over to it from RC1.At any rate, I've decided to just use a function that will create a new sprite on demand with all the properties I need. It seems to be 100 percent reliable and that's probably more important.
#4
greets
01/14/2010 (5:50 am)
we are having this problem too. did anyone find a fix for this randomly occuring bug?greets
Employee Melv May
Try dumping the classname to the console for both objects before you do the clone using the "%obj.getclassname()" call.
- Melv.