[deleted]
I have the following proof-of-concept:
It has a counter label at the top, and a board (grid) below. The grid is populated with cells on _ready()
(as there's too many to bother adding them manually via the UI). Each cell is also a grid (on a white background) and, on _ready()
, is similarly populated with tiles (blue squares - also too many to bother adding manually). Each tile responds to being clicked on, where it changes colour and emits a signal so the counter can update (counting the number of tiles that have been clicked).
I initially struggled to work out how to get a node in the main scene (the counter) to connect to signals coming from each tile, which aren't in the main scene. And no node in the main scene 'knows' about them either - since the main scene only has the Board node, which is programatically populated with Cell nodes, which are then programatically populated with Tile nodes. Eventually I found this video which showed how to trigger signals via an autoload script. I did that, and it works. But I wonder if that's the best solution here...
So my question is, is triggering a signal in the autoload script the best way to solve this problem? Or is there a more elegant solution here?