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 engine;
fn makeChild(parent: opaque, fname: string, init: bool) {
fn _makeChild(parent: opaque, fname: string, init: bool) {
var child: opaque = loadNode(fname);
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
@@ -16,12 +16,12 @@ fn onInit(node: opaque) {
print "root.toy:onInit() called";
//make a child
makeChild(node, "assets/scripts/child.toy", true); //indicate whether to call "init" on the new node or not
makeChild(node, "assets/scripts/child.toy", false);
makeChild(node, "assets/scripts/child.toy", false);
node.makeChild("assets/scripts/child.toy", true); //indicate whether to call "init" on the new node or not
node.makeChild("assets/scripts/child.toy", false);
node.makeChild("assets/scripts/child.toy", false);
//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) {

View File

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