Hi :D
I'm new here (and new to Godot). If this post is in the wrong section, I'm very sorry.
While playing around with the information provided by the "Getting Started"-Part of the docs, I came across something i can't find any explanation/solution for.
The scene has a panel as a parent node with a label and two buttons as children:
PanelNode
----LabelNode
----ButtonNode
----addchild
----SpriteNode
I let one button change the labeltext to the list of children (of the PanelNode I assume).
I let the other button add a sprite as another child.
Now, considering I used the "var SpriteNode" to create a new child I expected that clicking the "addchild"-Button multiple times would cause an error or overwrite the last added Sprite, however, it adds more and more which all should be named "SpriteNode".
How does this work?
Why does Godot not mind that there are multiple nodes with the same name?
And how do i access the SpriteNodes other than the last one?
The script:
extends Panel
var SpriteNode
var c
func _ready():
get_node("ButtonNode").connect("pressed", self, "_on_ButtonNode_pressed")
get_node("addchild").connect("pressed", self, "_on_addchild_pressed")
add_to_group("enemies")
func _on_ButtonNode_pressed():
c = get_children()
get_node("LabelNode").text = str(c)
func _on_addchild_pressed():
SpriteNode = Sprite.new()
add_child(SpriteNode)
I hope my question is somewhat clear.
Thank you :D