- Edited
Hello again !
How do I change the layering of my game to prevent this to happen :
This the only thing I activated :
Hello again !
How do I change the layering of my game to prevent this to happen :
This the only thing I activated :
I meant the one that are in front of my score are generated in a script. Is there a way to change the order after being created in script ?
var note_instance = note.instantiate()
note_instance.global_position.y = -65
get_parent().add_child(note_instance)
Reordering your spawning will also reorder the child but it seems like the text is not generated through script.
TheMikega how can you do to generate them into a node that's not higher than the scrore one
Safest way is to make a parent in which it's below the text. And you add child to that parent.
Is that UI element by the way? If that's the case and there are only 1 score board then what I would generally do is to not instantiate()
node for UI element when I can avoid it. I would just make it in the editor and just code the visibility. It will be easier to style and edit because it will be immediately clear what it would look like.
I have never seen that "Top level" parameter, what do they do? What node owns them?
pegasusearl I have never seen that "Top level" parameter, what do they do? What node owns them?
CanvasItem also has a z_index property that changes the rendering order.
xyz
pegasusearl
Nothing is working T_T
This is the tree before the game lauch
The "note" are the things that go in front of the score.
The score is show by the node called Game Manager throught a label node
Like this :
(it's was a node2d but I tryed to change it to a control node)
extends Control #Was Node2D before
var score = 0
func add_point():
score += 1
$Label.text = str(score)
func _ready():
var pos = Vector2(0,32)
func _process(delta):
if Input.is_action_just_pressed("click"):
add_point()
The "Spawn Notes" is a Node2D with a script that generate the "note" :
extends Node2D
var note = preload("res://scenes/note.tscn")
func _ready():
Player.connect("player_moved", moved)
func _process(delta):
pass
func moved():
var note_instance = note.instantiate()
note_instance.global_position.y = -65
get_parent().add_child(note_instance)
And this is the game tree while it's running
And this is how the game look ;
Also idk if it can help but the GameManager is autoloaded
TheMikega Nothing is working T_T
Everything suggested is in fact working. You're just not using it properly. Nodes are drawn from top to bottom as they are listed in the scene tree. So just make sure that you order them as you want them to be drawn. Also as @DaveTheCoder suggested, you can override this default drawing order by changing the z_index
property.
TheMikega It happens, we've all been there at some point in our lives.