NodeBase02 / 15

Finding and changing screen elements

Find the score display and board by their names in JSON.

In this example, board is inside gameplay, while score is directly under the root. From the root node’s component, find both elements, update the score text, and show the board.

const board = this.node.getChildContainer('gameplay.board');
const label = this.node.getChildText('score');
label.setText('120');
board.setVisible(true);
rootStart the lookup here
gameplay.boardShow the board
scoreUpdate the score text