Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
...I must be doing something wrong or the node-renaming after cloning is not working in WebGL :( This works as it should in Windows... var SourceNode = ccbGetSceneNodeFromName("NodeToClone");("NewName" is a var that's being incremented by 1 each time before another node is cloned) ...also this works great in Windows: var SourceNode = ccbGetSceneNodeFromName("NodeToClone");None of these work in WebGL at the moment of cloning. I can re-name node after cloning (with on-click action) but not in the moment/same pass as it's being cloned. It doesn't even adds number after the name, it just duplicates original-node name. That completely breaks WebGL version of my game :( Does anyone knows of any possible solution for this? |
||||
|
...so after two days I've finally figured it out: After cloning a node Windows build is changing node-references (like "this.MyNode") both in CC native scripts and in my custom scripts. WebGL build is changing ONLY native script references, not custom/user! So after I've changed all of the "this.MyNode" references with "node" or "currentnode" in my scripts things started to function :) Also my increment-var-number that I used for separating cloned names that worked in Windows build was this: var nameadd_var = ccbGetCopperCubeVariable("nameadd");...but in order to work in WebGL I needed to code it like this: var nameadd_var = ccbGetCopperCubeVariable("nameadd");Now number works in both Win & WebGL builds. So if anyone is targeting both Win & WebGL and has cloning of nodes with script-references like "this.MyNode"/"this.NodeName"/"this.Me": Use only "node" or "currentnode" references in your scripts. |
||||
|
This is the exact script that I was looking for a few weeks ago. Fantastic work! |
||||
|
Cheers, I'm glad someone else also found it useful. I never expected Windows & WebGL versions to have this kind of differences when it comes to code. In Windows builds all node-references in custom scripts that are references to the node itself get 'overwritten' with a new node-name when cloned. WebGL doesn't seem to do that, they all have to be 'node' or "currentnode", depending on what's specified inside a function brackets. |
||||
|
Thank you so much for providing truly an informative knowledge. I am glad to know about it. |
||||
|
You're welcome, it's always good to know that something you do can also be a benefit to others. Cheers! |
|