Hello again !
How do I change the layering of my game to prevent this to happen :

This the only thing I activated :

  • xyz replied to this.
  • 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.

    xyz My nodes auto generate, how can you do to generate them into a node that's not higher than the scrore one ?

      TheMikega What do you mean by "auto generate"? If you create them in code you can still control their order.

      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)
      • xyz replied to this.

        TheMikega You can use Node::move_child() to change node's position. Also you can add it at a certain position by using Node::add_sibling() instead of Node::add_child(). The latter always add the node as a last child which results in it being drawn on top of existing children.

          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?

            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

            • xyz replied to this.

              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.

                xyz I'm the stupidest person in the world, I understood it was writed from bottom to top and just by thinking of it, it make no sens. Thank you everyone for helping me, guess I was the problem ahah