Added sorting layers to nodes
This commit is contained in:
@@ -21,13 +21,9 @@ fn onInit(node: opaque) {
|
||||
|
||||
//load and initialize the UI (depends on map stuff)
|
||||
stepCounter = node.loadChild("scripts:/gameplay/step-counter.toy");
|
||||
stepCounter.setNodeRect(
|
||||
0,
|
||||
0,
|
||||
floor(TILE_PIXEL_WIDTH * MAP_GRID_WIDTH * tilemap.getNodeWorldScaleX()), //width - stretches along the top of the tilemap
|
||||
stepCounter.getNodeRectH() //default height
|
||||
);
|
||||
stepCounter.setNodeRect(0, 0, CAMERA_SCREEN_W, 32);
|
||||
stepCounter.callNodeFn("setMaxSteps", 100);
|
||||
stepCounter.setNodeLayer(100);
|
||||
|
||||
//offset the scene node, so it shows the map outside separate from the UI
|
||||
node.setNodePositionY(16);
|
||||
@@ -47,6 +43,17 @@ fn onFree(node: opaque) {
|
||||
fn onDraw(node: opaque) {
|
||||
//use the onDraw to sort - skip too many steps
|
||||
node.sortChildrenNode(depthComparator);
|
||||
|
||||
var scaleX: float = player.getNodeWorldScaleX();
|
||||
var scaleY: float = player.getNodeWorldScaleY();
|
||||
|
||||
//this offset is because the sprite cell for lejana is twice as big as the sprite cell for the floor tiles
|
||||
var originOffsetX: int = player.getNodeRectW() / 2;
|
||||
var originOffsetY: int = player.getNodeRectH() / 2;
|
||||
|
||||
//use the room scene's onDraw to set the global camera position
|
||||
globalCameraX = floor((CAMERA_SCREEN_W / 2) - (player.getNodeWorldPositionX() * scaleX)) - originOffsetX;
|
||||
globalCameraY = floor((CAMERA_SCREEN_H / 2) - (player.getNodeWorldPositionY() * scaleY)) - originOffsetY;
|
||||
}
|
||||
|
||||
//gameplay functions
|
||||
|
||||
Reference in New Issue
Block a user