Trying to render faster...
This commit is contained in:
@@ -12,7 +12,6 @@ fn onDraw(node: opaque) {
|
|||||||
var posX: int const = node.getNodeWorldPositionX();
|
var posX: int const = node.getNodeWorldPositionX();
|
||||||
var posY: int const = node.getNodeWorldPositionY();
|
var posY: int const = node.getNodeWorldPositionY();
|
||||||
|
|
||||||
//draw everything at twice the original size
|
|
||||||
var scaleX: float const = node.getNodeWorldScaleX();
|
var scaleX: float const = node.getNodeWorldScaleX();
|
||||||
var scaleY: float const = node.getNodeWorldScaleY();
|
var scaleY: float const = node.getNodeWorldScaleY();
|
||||||
|
|
||||||
|
|||||||
@@ -20,22 +20,22 @@ var CELL_COUNT_X: int const = 3;
|
|||||||
var CELL_COUNT_Y: int const = 3;
|
var CELL_COUNT_Y: int const = 3;
|
||||||
|
|
||||||
|
|
||||||
var tilemap: [int] = null;
|
|
||||||
|
|
||||||
//lifecycle functions
|
//lifecycle functions
|
||||||
fn onLoad(node: opaque) {
|
fn onLoad(node: opaque) {
|
||||||
//load the atlas into this node
|
//load the atlas into this node
|
||||||
node.loadNodeTexture("sprites:/tileset.png");
|
node.loadNodeTexture("sprites:/tileset.png");
|
||||||
}
|
|
||||||
|
|
||||||
fn setTilemap(node: opaque, t: [int]) {
|
|
||||||
assert t, "provided tilemap is null (in setTilemap)";
|
|
||||||
|
|
||||||
tilemap = t;
|
|
||||||
|
|
||||||
//create a child as a render target
|
//create a child as a render target
|
||||||
var child = node.loadChildNode("scripts:/tilemap/renderer-child.toy");
|
var child: opaque = node.loadChildNode("scripts:/tilemap/renderer-child.toy");
|
||||||
child.createNodeTexture(CELL_WIDTH * CELL_COUNT_X * TILE_PIXEL_WIDTH, CELL_HEIGHT * CELL_COUNT_Y * TILE_PIXEL_HEIGHT);
|
child.createNodeTexture(CELL_WIDTH * CELL_COUNT_X * TILE_PIXEL_WIDTH, CELL_HEIGHT * CELL_COUNT_Y * TILE_PIXEL_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setTilemap(node: opaque, tilemap: [int]) {
|
||||||
|
assert tilemap, "provided tilemap is null (in setTilemap)";
|
||||||
|
|
||||||
|
print "start setting tilemap";
|
||||||
|
|
||||||
|
var child: opaque = node.getChildNode(0);
|
||||||
setRenderTarget(child);
|
setRenderTarget(child);
|
||||||
|
|
||||||
//draw the tilemap to the child
|
//draw the tilemap to the child
|
||||||
@@ -65,4 +65,6 @@ fn setTilemap(node: opaque, t: [int]) {
|
|||||||
|
|
||||||
//reset the render target to the screen
|
//reset the render target to the screen
|
||||||
setRenderTarget(null);
|
setRenderTarget(null);
|
||||||
|
|
||||||
|
print "finished setting tilemap";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user