This commit is contained in:
2022-10-08 18:23:17 +01:00
parent 2b0e71b6fb
commit 500983358d
2 changed files with 11 additions and 11 deletions

View File

@@ -1,14 +1,14 @@
import standard; import standard;
import engine; import engine;
fn makeChild(parent: opaque, fname: string, init: bool) { fn _makeChild(parent: opaque, fname: string, init: bool) {
var child: opaque = loadNode(fname); var child: opaque = loadNode(fname);
if (init) { if (init) {
initNode(child); child.initNode();
} }
pushNode(parent, child); parent.pushNode(child);
} }
//root node can load the whole scene, and essentially act as the scene object //root node can load the whole scene, and essentially act as the scene object
@@ -16,12 +16,12 @@ fn onInit(node: opaque) {
print "root.toy:onInit() called"; print "root.toy:onInit() called";
//make a child //make a child
makeChild(node, "assets/scripts/child.toy", true); //indicate whether to call "init" on the new node or not node.makeChild("assets/scripts/child.toy", true); //indicate whether to call "init" on the new node or not
makeChild(node, "assets/scripts/child.toy", false); node.makeChild("assets/scripts/child.toy", false);
makeChild(node, "assets/scripts/child.toy", false); node.makeChild("assets/scripts/child.toy", false);
//actually, grab that first node and free it //actually, grab that first node and free it
freeChildNode(node, 0); //must be done from the parent node, so it's pointer can be nullified node.freeChildNode(0); //must be done from the parent node, so it's pointer can be nullified
} }
fn onStep(node: opaque) { fn onStep(node: opaque) {

View File

@@ -421,11 +421,11 @@ int hookEngine(Interpreter* interpreter, Literal identifier, Literal alias) {
{"initWindow", nativeInitWindow}, {"initWindow", nativeInitWindow},
{"loadRootNode", nativeLoadRootNode}, {"loadRootNode", nativeLoadRootNode},
{"loadNode", nativeLoadNode}, {"loadNode", nativeLoadNode},
{"initNode", nativeInitNode}, {"_initNode", nativeInitNode},
// {"freeNode", nativeFreeNode}, // {"freeNode", nativeFreeNode},
{"freeChildNode", nativeFreeChildNode}, {"_freeChildNode", nativeFreeChildNode},
{"pushNode", nativePushNode}, {"_pushNode", nativePushNode},
{"getNode", nativeGetNode}, {"_getNode", nativeGetNode},
{NULL, NULL} {NULL, NULL}
}; };