I forgot what I was doing because it's 4:30am
This commit is contained in:
@@ -1,18 +1,54 @@
|
||||
import engine;
|
||||
import node;
|
||||
|
||||
//variables
|
||||
var parent: opaque = null;
|
||||
var x: int = 50;
|
||||
var y: int = 50;
|
||||
|
||||
//accessors
|
||||
fn getX() {
|
||||
print "Called getX";
|
||||
return x;
|
||||
}
|
||||
|
||||
fn getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
//lifecycle functions
|
||||
fn onInit(node: opaque) {
|
||||
node.loadTextureEngineNode("assets/sprites/character.png");
|
||||
print "render.toy:onInit() called";
|
||||
|
||||
node.loadTexture("assets/sprites/character.png");
|
||||
print "loaded texture";
|
||||
|
||||
parent = node.getNodeParent();
|
||||
print "accessed parent";
|
||||
}
|
||||
|
||||
fn onStep(node: opaque) {
|
||||
//
|
||||
print "render.toy:onStep()";
|
||||
}
|
||||
|
||||
fn onFree(node: opaque) {
|
||||
node.freeTextureEngineNode();
|
||||
print "render.toy:onFree() called";
|
||||
|
||||
node.freeTexture();
|
||||
}
|
||||
|
||||
fn onDraw(node: opaque) {
|
||||
node.drawEngineNode(50, 50, 100, 100);
|
||||
}
|
||||
//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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user