I decided to make/clone minesweeper. As I figured out I should manipulate input somehow. I guess it should be signals, but I have no idea how to connect them since I can't use godot interface to do so, because cells is an instanciated objects by add_child() method.
Correct me if I wrong: I declare a signal on cell scene's script, so every instantiated scene node(of the cell) should have it's own signal?(i.e. when I click individual cell in a gridcontainer, where cell added as a child, it should affect only that instance of the cell). But how exactly should I connect them to main script where all calculations happen?
If I should use this:
func _at_some_func():
instance.connect("your_signal_name", self, "_callback_no_args")
How do I connect instance if I don't know its exact name. And there's a lot instances to sort them manually
How project generally looks: Main scene: Node2D - GgridCOntainer
main.gd
extends Node2D
variables
func _ready():
matrix()
func matrix():
while true:
var cell = Cell.instance()
$GridContainer.add_child(cell)
And Cell scene: Container
Cell.gd
extends Container
signal clicked
variables
func _input():
if cell_state == HIDDEN and event.is_action_pressed("click"):
cell_state[0] = OPEN
emit_signal("clicked")
Or maybe there other way(s) to solve this problem wich I don't see?