Added variable argument count to callNode
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
fn onInit(node: opaque) {
|
||||
print "child.toy:onInit() called";
|
||||
}
|
||||
|
||||
fn onStep(node: opaque) {
|
||||
print "child.toy:onStep()";
|
||||
}
|
||||
|
||||
fn onFree(node: opaque) {
|
||||
print "child.toy:onFree() called";
|
||||
}
|
||||
@@ -28,6 +28,35 @@ fn onInit(node: opaque) {
|
||||
parent = node.getNodeParent();
|
||||
}
|
||||
|
||||
fn onStep(node: opaque) {
|
||||
x += xspeed;
|
||||
y += yspeed;
|
||||
}
|
||||
|
||||
fn onFree(node: opaque) {
|
||||
print "render.toy:onFree() called";
|
||||
|
||||
node.freeTexture();
|
||||
}
|
||||
|
||||
fn onDraw(node: opaque) {
|
||||
// print "render.toy:onDraw() called";
|
||||
|
||||
var px = parent.callNode("getX");
|
||||
var py = parent.callNode("getY");
|
||||
|
||||
if (px == null) {
|
||||
px = 0;
|
||||
}
|
||||
|
||||
if (py == null) {
|
||||
py = 0;
|
||||
}
|
||||
|
||||
node.drawNode(x + px, y + py, 100, 100);
|
||||
}
|
||||
|
||||
//event functions
|
||||
fn onKeyDown(node: opaque, event: string) {
|
||||
if (event == "character_up") {
|
||||
yspeed -= SPEED;
|
||||
@@ -70,32 +99,4 @@ fn onKeyUp(node: opaque, event: string) {
|
||||
xspeed = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fn onStep(node: opaque) {
|
||||
x += xspeed;
|
||||
y += yspeed;
|
||||
}
|
||||
|
||||
fn onFree(node: opaque) {
|
||||
print "render.toy:onFree() called";
|
||||
|
||||
node.freeTexture();
|
||||
}
|
||||
|
||||
fn onDraw(node: opaque) {
|
||||
// print "render.toy:onDraw() called";
|
||||
|
||||
var px = parent.callNode("getX");
|
||||
var py = parent.callNode("getY");
|
||||
|
||||
if (px == null) {
|
||||
px = 0;
|
||||
}
|
||||
|
||||
if (py == null) {
|
||||
py = 0;
|
||||
}
|
||||
|
||||
node.drawNode(x + px, y + py, 100, 100);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ mapInputEventToKeyUp("character_left", "left"); //event, keysym
|
||||
mapInputEventToKeyUp("character_down", "down"); //event, keysym
|
||||
mapInputEventToKeyUp("character_right", "right"); //event, keysym
|
||||
|
||||
|
||||
//this function must always be called, or the engine won't run
|
||||
initWindow("Airport Game", 800, 600, false);
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
import engine;
|
||||
import node;
|
||||
|
||||
//util to generate and init a child node of a parent
|
||||
fn _makeChild(parent: opaque, fname: string) {
|
||||
var child: opaque = loadNode(fname);
|
||||
parent.pushNode(child);
|
||||
child.initNode();
|
||||
}
|
||||
|
||||
//root node can load the whole scene, and essentially act as the scene object
|
||||
//NOTE: root node can load the whole scene, and essentially act as the scene object
|
||||
fn onInit(node: opaque) {
|
||||
print "root.toy:onInit() called";
|
||||
|
||||
//make a child
|
||||
// node.makeChild("assets/scripts/child.toy");
|
||||
// node.makeChild("assets/scripts/child.toy");
|
||||
node.makeChild("assets/scripts/render.toy");
|
||||
node.makeChild("assets/scripts/entity.toy");
|
||||
|
||||
node.getNodeChild(0).makeChild("assets/scripts/render.toy");
|
||||
//give the child a child
|
||||
node.getNodeChild(0).makeChild("assets/scripts/entity.toy");
|
||||
}
|
||||
|
||||
fn onStep(node: opaque) {
|
||||
|
||||
Reference in New Issue
Block a user