Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi All. I am trying to clone a node, I seem to clone it successfully, however I then want the script to check if the node has been cloned. I tried: var s = ccbGetSceneNodeFromName(name_of_new_node); if (s) print("found node.\n"); else print("not found the node.\n") But it never detects the new node. I am using this script to clone the node var sourceNode = ccbGetSceneNodeFromName("myNode"); var newscenenode = ccbCloneSceneNode(sourceNode); |
||||
|
I just finished an epic workaround with this exact topic successfully. You need to change the name of the new cloned object so it wont get lumped together with the original object. The default will have 2 objects with the exact same name. (some have said it will separate this by itself but not from my experience). I add a number at the end each time and just record that as a CC variable. To check and see what child nodes have been created run this code: (I have all my items inside a folder called "Loot") var node = ccbGetSceneNodeFromName("Loot"); var count = ccbGetSceneNodeChildCount(node); for(var i=0; i<count; i++) { var child = ccbGetChildSceneNode(node, i); print("node:" + ccbGetSceneNodeProperty(child, "Name") + "\n"); } |
||||
|
Zoo wrote: Hi All. I am trying to clone a node, I seem to clone it successfully, however I then want the script to check if the node has been cloned. I tried: var s = ccbGetSceneNodeFromName(name_of_new_node); if (s) print("found node.\n"); else print("not found the node.\n") But it never detects the new node. I am using this script to clone the node var sourceNode = ccbGetSceneNodeFromName("myNode"); var newscenenode = ccbCloneSceneNode(sourceNode); This is my code to populate my game with cloned object - saved with position & rotation (7 items in the array per object, name, pos & rot): var len = invVol.length; //my array for world objects var nu = ccbGetCopperCubeVariable("cloneNu"); for (var i=0; i<len; i=i+7) { var item = invVol[i]; var pos = invVol[i+1] +","+ invVol[i+2] + "," + invVol[i+3]; var rot = invVol[i+4] +","+ invVol[i+5] +","+ invVol[i+6]; nu++; var newName = item + nu; var node = ccbGetSceneNodeFromName(item); var clone = ccbCloneSceneNode(node); ccbSetSceneNodeProperty(clone, "Name", newName); ccbSetSceneNodeProperty(clone, "Position", pos); ccbSetSceneNodeProperty(clone, "Rotation", rot); ccbSetSceneNodeProperty(clone, "Visible", true); } ccbSetCopperCubeVariable("cloneNu", nu); |
|