Godot Version
godot 4.3
Question
Hello. I’m following the “Slay the Spire clone” tutorial here (using Godot 4.3):
And got problem with the reparent()
method not working in expected way.
Basically, an HBoxContainer
is attached to a script hand.gd
, which has a function _on_card_ui_reparent_requested
. CardUI
is a subclass the Control
:
class_name Hand
extends HBoxContainer
func _ready() -> void:
for child in get_children():
var card_ui := child as CardUI
card_ui.reparent_requested.connect(_on_card_ui_reparent_requested)
func _on_card_ui_reparent_requested(child: CardUI) -> void:
print("hand got request reparent", child, self)
child.reparent(self)
- The signal
card_ui.reparent_requested
is emitted when a game card object instance (card_ui) is dropped in non-target zone. - The
Hand._on_card_ui_reparent_requested
should be called with the card object to be snapped back into theHand
container by callingchild.reparent(self)
. - I’ve checked
_on_card_ui_reparent_requested
is called with what seems to be the correctchild
andself
. But thechild
was never reparent to theself
(Hand
).
How best to start debugging this?