≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
how to get scene node parent?
Posted by:
(you are not logged in)
Enter the missing letter in: "Internati?nal"
(you are not logged in)
Text:
[quote][b][/b] wrote: [code]function getNodeParent(nodeToFind) { function findNode(nodeToFind, curNode, parent) { var nodeToFindName = ccbGetSceneNodeProperty(nodeToFind, 'Name'); var curNodeName = ccbGetSceneNodeProperty(curNode, 'Name'); if (nodeToFindName === curNodeName) { return parent; } else { var result = null; for (var i = 0; result === null && i < ccbGetSceneNodeChildCount(curNode); i++) { var child = ccbGetChildSceneNode(curNode, i); result = findNode(nodeToFind, child, curNode); } return result; } } var root = ccbGetRootSceneNode(); var result = null; for (var i = 0; result === null && i < ccbGetSceneNodeChildCount(root); i++) { var child = ccbGetChildSceneNode(root, i); result = findNode(nodeToFind, child, root); } return result; }[/code] Sorry, not that elegant solution, but it kinda works for me. The biggest issue is that it compares nodes by names, so all your nodes should have the unique ones for the function to work. It would be really nice to get nodes IDs somehow, but I don't think it's possible.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact