@@ -106,18 +106,26 @@ Tree order
106106----------
107107
108108Most node operations in Godot, such as drawing 2D, processing, or getting
109- notifications are done in tree order, or top to bottom. For example, the
110- top node in a scene has its ``_ready() `` function called first, then the
111- node below it has its function called, then the node below that and so
112- on. However, children of a node will get called before their parent, also
113- in top to bottom order. So the top child node of the top node will get its
114- ``_ready() `` function called first.
109+ notifications are done in *tree order *, or top to bottom as seen in the
110+ editor (also known as pre-order traversal):
115111
116112.. image :: img/toptobottom.webp
117113
118- This can also be overridden using the ``process_priority `` node property.
119- Nodes with a lower number are called first. For example, nodes with the
120- priorities "0, 1, 2, 3" would be called in that order (from left to right).
114+ For example, the top node in a scene has its ``_process() `` function
115+ called first, then the node below it has its ``_process() `` function called,
116+ then the node below that and so on.
117+
118+ An important exception is the ``_ready() `` function: each parent node has its
119+ ``_ready() `` function called only after all its child nodes have their
120+ ``_ready() `` functions called, so that the parent knows its children are
121+ completely ready to be accessed. This is also known as post-order traversal.
122+ In the above image, ``NameLabel `` would be notified first (but only after its
123+ children, if it had any!), followed by ``Name ``, etc., and ``Panel `` would be
124+ notified last.
125+
126+ The order of operations can also be overridden using the ``process_priority ``
127+ node property. Nodes with a lower number are called first. For example, nodes
128+ with the priorities "0, 1, 2, 3" would be called in that order from left to right.
121129
122130"Becoming active" by entering the *Scene Tree *
123131----------------------------------------------
@@ -126,15 +134,15 @@ priorities "0, 1, 2, 3" would be called in that order (from left to right).
126134#. The root node of that scene (only one root, remember?) is added as
127135 either a child of the "root" Viewport (from SceneTree), or to any
128136 of its descendants.
129- #. Every node of the newly added scene, will receive the "enter_tree"
137+ #. Every node of the newly added scene will receive the "enter_tree"
130138 notification ( ``_enter_tree() `` callback in GDScript) in
131- top-to-bottom order.
132- #. An extra notification, "ready" ( ``_ready() `` callback in GDScript)
133- is provided for convenience, when a node and all its children are
134- inside the active scene .
139+ top-to-bottom order (pre-order traversal) .
140+ #. Every node will receive the "ready" notification ( ``_ready() ``
141+ callback in GDScript) for convenience, once all its children have
142+ received the "ready" notification (post-order traversal) .
135143#. When a scene (or part of it) is removed, they receive the "exit
136144 scene" notification ( ``_exit_tree() `` callback in GDScript) in
137- bottom-to-top order
145+ bottom-to-top order (the exact reverse of top-to-bottom order).
138146
139147Changing current scene
140148----------------------
0 commit comments