Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Robster | |
Old Version | Published before Godot 3 was released. |
I have the tree as:
Root
- gameLevel
-- HUD
---HBoxContainer
This is the code:
func drawLifeIndicators():
var containerBox = get_node("HUD/HBoxContainer")
var scene = load("res://batMini.tscn")
var newBatMini
for i in range(0, globals.lives):
newBatMini = scene.instance()
print("adding mini")
#containerBox.add_spacer(true)
containerBox.add_child(newBatMini)
If I check the inspector, yes, all 3 (in this case) life indicators show up as direct children of the HBoxContainer, BUT they all appear to be showing up in the same physical place. Can anyone see why they’re being generated in the same position?
What node types are your “life indicators”? If they are not Control-based (ie a ‘green’ node), they won’t align themselves within a container.
YeOldeDM | 2017-04-24 17:06
Yes you were correct. I changed it to a control base and it NEARLY worked. Then by adding volzhs’s answer to the solution it all came together. Thanks for the help.
Robster | 2017-04-25 03:36