class_node.rst 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Node:
  4. Node
  5. ====
  6. **Inherits:** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`Viewport<class_viewport>`, :ref:`Timer<class_timer>`, :ref:`CanvasLayer<class_canvaslayer>`, :ref:`EventPlayer<class_eventplayer>`, :ref:`SoundRoomParams<class_soundroomparams>`, :ref:`Tween<class_tween>`, :ref:`Spatial<class_spatial>`, :ref:`AnimationPlayer<class_animationplayer>`, :ref:`EditorPlugin<class_editorplugin>`, :ref:`ResourcePreloader<class_resourcepreloader>`, :ref:`AnimationTreePlayer<class_animationtreeplayer>`, :ref:`SamplePlayer<class_sampleplayer>`, :ref:`InstancePlaceholder<class_instanceplaceholder>`, :ref:`HTTPRequest<class_httprequest>`, :ref:`StreamPlayer<class_streamplayer>`, :ref:`CanvasItem<class_canvasitem>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Base class for all the *scene* elements.
  12. Member Functions
  13. ----------------
  14. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`_enter_tree<class_Node__enter_tree>` **(** **)** virtual |
  16. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`_exit_tree<class_Node__exit_tree>` **(** **)** virtual |
  18. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`_fixed_process<class_Node__fixed_process>` **(** :ref:`float<class_float>` delta **)** virtual |
  20. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`_input<class_Node__input>` **(** :ref:`InputEvent<class_inputevent>` event **)** virtual |
  22. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`_process<class_Node__process>` **(** :ref:`float<class_float>` delta **)** virtual |
  24. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`_ready<class_Node__ready>` **(** **)** virtual |
  26. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`_unhandled_input<class_Node__unhandled_input>` **(** :ref:`InputEvent<class_inputevent>` event **)** virtual |
  28. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`_unhandled_key_input<class_Node__unhandled_key_input>` **(** :ref:`InputEvent<class_inputevent>` key_event **)** virtual |
  30. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`add_child<class_Node_add_child>` **(** :ref:`Node<class_node>` node, :ref:`bool<class_bool>` legible_unique_name=false **)** |
  32. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`add_to_group<class_Node_add_to_group>` **(** :ref:`String<class_string>` group, :ref:`bool<class_bool>` persistent=false **)** |
  34. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`can_process<class_Node_can_process>` **(** **)** const |
  36. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Node<class_node>` | :ref:`duplicate<class_Node_duplicate>` **(** :ref:`bool<class_bool>` use_instancing=false, :ref:`int<class_int>` flags=7 **)** const |
  38. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Node<class_node>` | :ref:`find_node<class_Node_find_node>` **(** :ref:`String<class_string>` mask, :ref:`bool<class_bool>` recursive=true, :ref:`bool<class_bool>` owned=true **)** const |
  40. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Node<class_node>` | :ref:`get_child<class_Node_get_child>` **(** :ref:`int<class_int>` idx **)** const |
  42. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_child_count<class_Node_get_child_count>` **(** **)** const |
  44. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Array<class_array>` | :ref:`get_children<class_Node_get_children>` **(** **)** const |
  46. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`String<class_string>` | :ref:`get_filename<class_Node_get_filename>` **(** **)** const |
  48. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_fixed_process_delta_time<class_Node_get_fixed_process_delta_time>` **(** **)** const |
  50. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Array<class_array>` | :ref:`get_groups<class_Node_get_groups>` **(** **)** const |
  52. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`get_index<class_Node_get_index>` **(** **)** const |
  54. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`String<class_string>` | :ref:`get_name<class_Node_get_name>` **(** **)** const |
  56. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Node<class_node>` | :ref:`get_node<class_Node_get_node>` **(** :ref:`NodePath<class_nodepath>` path **)** const |
  58. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Array<class_array>` | :ref:`get_node_and_resource<class_Node_get_node_and_resource>` **(** :ref:`NodePath<class_nodepath>` path **)** |
  60. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`Node<class_node>` | :ref:`get_owner<class_Node_get_owner>` **(** **)** const |
  62. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Node<class_node>` | :ref:`get_parent<class_Node_get_parent>` **(** **)** const |
  64. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`NodePath<class_nodepath>` | :ref:`get_path<class_Node_get_path>` **(** **)** const |
  66. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`NodePath<class_nodepath>` | :ref:`get_path_to<class_Node_get_path_to>` **(** :ref:`Node<class_node>` node **)** const |
  68. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`int<class_int>` | :ref:`get_pause_mode<class_Node_get_pause_mode>` **(** **)** const |
  70. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`int<class_int>` | :ref:`get_position_in_parent<class_Node_get_position_in_parent>` **(** **)** const |
  72. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`float<class_float>` | :ref:`get_process_delta_time<class_Node_get_process_delta_time>` **(** **)** const |
  74. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`get_scene_instance_load_placeholder<class_Node_get_scene_instance_load_placeholder>` **(** **)** const |
  76. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`SceneTree<class_scenetree>` | :ref:`get_tree<class_Node_get_tree>` **(** **)** const |
  78. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`Object<class_object>` | :ref:`get_viewport<class_Node_get_viewport>` **(** **)** const |
  80. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`has_node<class_Node_has_node>` **(** :ref:`NodePath<class_nodepath>` path **)** const |
  82. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`has_node_and_resource<class_Node_has_node_and_resource>` **(** :ref:`NodePath<class_nodepath>` path **)** const |
  84. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_a_parent_of<class_Node_is_a_parent_of>` **(** :ref:`Node<class_node>` node **)** const |
  86. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`bool<class_bool>` | :ref:`is_displayed_folded<class_Node_is_displayed_folded>` **(** **)** const |
  88. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`bool<class_bool>` | :ref:`is_fixed_processing<class_Node_is_fixed_processing>` **(** **)** const |
  90. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`bool<class_bool>` | :ref:`is_greater_than<class_Node_is_greater_than>` **(** :ref:`Node<class_node>` node **)** const |
  92. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`bool<class_bool>` | :ref:`is_in_group<class_Node_is_in_group>` **(** :ref:`String<class_string>` group **)** const |
  94. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`is_inside_tree<class_Node_is_inside_tree>` **(** **)** const |
  96. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`is_processing<class_Node_is_processing>` **(** **)** const |
  98. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`is_processing_input<class_Node_is_processing_input>` **(** **)** const |
  100. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`is_processing_unhandled_input<class_Node_is_processing_unhandled_input>` **(** **)** const |
  102. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`bool<class_bool>` | :ref:`is_processing_unhandled_key_input<class_Node_is_processing_unhandled_key_input>` **(** **)** const |
  104. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`move_child<class_Node_move_child>` **(** :ref:`Node<class_node>` child_node, :ref:`int<class_int>` to_pos **)** |
  106. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`print_stray_nodes<class_Node_print_stray_nodes>` **(** **)** |
  108. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`print_tree<class_Node_print_tree>` **(** **)** |
  110. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`propagate_notification<class_Node_propagate_notification>` **(** :ref:`int<class_int>` what **)** |
  112. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`queue_free<class_Node_queue_free>` **(** **)** |
  114. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`raise<class_Node_raise>` **(** **)** |
  116. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`remove_and_skip<class_Node_remove_and_skip>` **(** **)** |
  118. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`remove_child<class_Node_remove_child>` **(** :ref:`Node<class_node>` node **)** |
  120. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`remove_from_group<class_Node_remove_from_group>` **(** :ref:`String<class_string>` group **)** |
  122. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`replace_by<class_Node_replace_by>` **(** :ref:`Node<class_node>` node, :ref:`bool<class_bool>` keep_data=false **)** |
  124. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`set_display_folded<class_Node_set_display_folded>` **(** :ref:`bool<class_bool>` fold **)** |
  126. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`set_filename<class_Node_set_filename>` **(** :ref:`String<class_string>` filename **)** |
  128. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`set_fixed_process<class_Node_set_fixed_process>` **(** :ref:`bool<class_bool>` enable **)** |
  130. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | void | :ref:`set_name<class_Node_set_name>` **(** :ref:`String<class_string>` name **)** |
  132. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | void | :ref:`set_owner<class_Node_set_owner>` **(** :ref:`Node<class_node>` owner **)** |
  134. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | void | :ref:`set_pause_mode<class_Node_set_pause_mode>` **(** :ref:`int<class_int>` mode **)** |
  136. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | void | :ref:`set_process<class_Node_set_process>` **(** :ref:`bool<class_bool>` enable **)** |
  138. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | void | :ref:`set_process_input<class_Node_set_process_input>` **(** :ref:`bool<class_bool>` enable **)** |
  140. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | void | :ref:`set_process_unhandled_input<class_Node_set_process_unhandled_input>` **(** :ref:`bool<class_bool>` enable **)** |
  142. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | void | :ref:`set_process_unhandled_key_input<class_Node_set_process_unhandled_key_input>` **(** :ref:`bool<class_bool>` enable **)** |
  144. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | void | :ref:`set_scene_instance_load_placeholder<class_Node_set_scene_instance_load_placeholder>` **(** :ref:`bool<class_bool>` load_placeholder **)** |
  146. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. Signals
  148. -------
  149. - **enter_tree** **(** **)**
  150. - **exit_tree** **(** **)**
  151. - **renamed** **(** **)**
  152. Emitted when the node is renamed.
  153. Numeric Constants
  154. -----------------
  155. - **NOTIFICATION_ENTER_TREE** = **10**
  156. - **NOTIFICATION_EXIT_TREE** = **11**
  157. - **NOTIFICATION_MOVED_IN_PARENT** = **12**
  158. - **NOTIFICATION_READY** = **13**
  159. - **NOTIFICATION_FIXED_PROCESS** = **16**
  160. - **NOTIFICATION_PROCESS** = **17** --- Notification received every frame when the process flag is set (see :ref:`set_process<class_Node_set_process>`).
  161. - **NOTIFICATION_PARENTED** = **18** --- Notification received when a node is set as a child of another node. Note that this doesn't mean that a node entered the Scene Tree.
  162. - **NOTIFICATION_UNPARENTED** = **19** --- Notification received when a node is unparented (parent removed it from the list of children).
  163. - **NOTIFICATION_PAUSED** = **14**
  164. - **NOTIFICATION_UNPAUSED** = **15**
  165. - **NOTIFICATION_INSTANCED** = **20**
  166. - **NOTIFICATION_DRAG_BEGIN** = **21**
  167. - **NOTIFICATION_DRAG_END** = **22**
  168. - **PAUSE_MODE_INHERIT** = **0**
  169. - **PAUSE_MODE_STOP** = **1**
  170. - **PAUSE_MODE_PROCESS** = **2**
  171. - **DUPLICATE_SIGNALS** = **1**
  172. - **DUPLICATE_GROUPS** = **2**
  173. - **DUPLICATE_SCRIPTS** = **4**
  174. Description
  175. -----------
  176. Nodes are the base bricks with which Godot games are developed. They can be set as children of other nodes, resulting in a tree arrangement. A given node can contain any number of nodes as children (but there is only one scene tree root node) with the requirement that all siblings (direct children of a node) should have unique names.
  177. Any tree of nodes is called a *scene*. Scenes can be saved to the disk and then instanced into other scenes. This allows for very high flexibility in the architecture and data model of the projects. Nodes can optionally be added to groups. This makes it easy to reach a number of nodes from the code (for example an "enemies" group) to perform grouped actions.
  178. **Scene tree:** The :ref:`SceneTree<class_scenetree>` contains the active tree of nodes. When a node is added to the scene tree, it receives the NOTIFICATION_ENTER_TREE notification and its :ref:`_enter_tree<class_Node__enter_tree>` callback is triggered. Children nodes are always added *after* their parent node, i.e. the :ref:`_enter_tree<class_Node__enter_tree>` callback of a parent node will be triggered before its child's.
  179. Once all nodes have been added in the scene tree, they receive the NOTIFICATION_READY notification and their respective :ref:`_ready<class_Node__ready>` callbacks are triggered. For groups of nodes, the :ref:`_ready<class_Node__ready>` callback is called in reverse order, from the children up to the parent nodes.
  180. It means that when adding a scene to the scene tree, the following order will be used for the callbacks: :ref:`_enter_tree<class_Node__enter_tree>` of the parent, :ref:`_enter_tree<class_Node__enter_tree>` of the children, :ref:`_ready<class_Node__ready>` of the children and finally :ref:`_ready<class_Node__ready>` of the parent (and that recursively for the whole scene).
  181. **Processing:** Nodes can be set to the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback :ref:`_process<class_Node__process>`, toggled with :ref:`set_process<class_Node_set_process>`) happens as fast as possible and is dependent on the frame rate, so the processing time *delta* is variable. Fixed processing (callback :ref:`_fixed_process<class_Node__fixed_process>`, toggled with :ref:`set_fixed_process<class_Node_set_fixed_process>`) happens a fixed amount of times per second (by default 60) and is useful to link itself to the physics.
  182. Nodes can also process input events. When set, the :ref:`_input<class_Node__input>` function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the :ref:`_unhandled_input<class_Node__unhandled_input>` function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI :ref:`Control<class_control>` nodes), ensuring that the node only receives the events that were meant for it.
  183. To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with :ref:`set_owner<class_Node_set_owner>`. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.
  184. Finally, when a node is freed with :ref:`free<class_Node_free>` or :ref:`queue_free<class_Node_queue_free>`, it will also free all its children.
  185. Member Function Description
  186. ---------------------------
  187. .. _class_Node__enter_tree:
  188. - void **_enter_tree** **(** **)** virtual
  189. Called when the node enters the :ref:`SceneTree<class_scenetree>` (e.g. upon instancing, scene changing or after calling :ref:`add_child<class_Node_add_child>` in a script). If the node has children, its :ref:`_enter_tree<class_Node__enter_tree>` callback will be called first, and then that of the children.
  190. Corresponds to the NOTIFICATION_ENTER_TREE notification in :ref:`Object._notification<class_Object__notification>`.
  191. .. _class_Node__exit_tree:
  192. - void **_exit_tree** **(** **)** virtual
  193. Called when the node leaves the :ref:`SceneTree<class_scenetree>` (e.g. upon freeing, scene changing or after calling :ref:`remove_child<class_Node_remove_child>` in a script). If the node has children, its :ref:`_exit_tree<class_Node__exit_tree>` callback will be called last, after all its children have left the tree.
  194. Corresponds to the NOTIFICATION_EXIT_TREE notification in :ref:`Object._notification<class_Object__notification>`.
  195. .. _class_Node__fixed_process:
  196. - void **_fixed_process** **(** :ref:`float<class_float>` delta **)** virtual
  197. Called during the fixed processing step of the main loop. Fixed processing means that the frame rate is synced to the physics, i.e. the ``delta`` variable should be constant.
  198. It is only called if fixed processing has been enabled with :ref:`set_fixed_process<class_Node_set_fixed_process>`.
  199. Corresponds to the NOTIFICATION_FIXED_PROCESS notification in :ref:`Object._notification<class_Object__notification>`.
  200. .. _class_Node__input:
  201. - void **_input** **(** :ref:`InputEvent<class_inputevent>` event **)** virtual
  202. Called for every input event.
  203. It has to be enabled with :ref:`set_process_input<class_Node_set_process_input>` or the corresponding property in the inspector.
  204. .. _class_Node__process:
  205. - void **_process** **(** :ref:`float<class_float>` delta **)** virtual
  206. Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the ``delta`` time since the previous frame is not constant.
  207. It is only called if processing has been enabled with :ref:`set_process<class_Node_set_process>`.
  208. Corresponds to the NOTIFICATION_PROCESS notification in :ref:`Object._notification<class_Object__notification>`.
  209. .. _class_Node__ready:
  210. - void **_ready** **(** **)** virtual
  211. Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their :ref:`_ready<class_Node__ready>` callback gets triggered first, and the node will receive the ready notification only afterwards.
  212. Corresponds to the NOTIFICATION_READY notification in :ref:`Object._notification<class_Object__notification>`.
  213. .. _class_Node__unhandled_input:
  214. - void **_unhandled_input** **(** :ref:`InputEvent<class_inputevent>` event **)** virtual
  215. Called for every input event that has not already been handled by another node.
  216. It has to be enabled with :ref:`set_process_unhandled_input<class_Node_set_process_unhandled_input>` or the corresponding property in the inspector.
  217. .. _class_Node__unhandled_key_input:
  218. - void **_unhandled_key_input** **(** :ref:`InputEvent<class_inputevent>` key_event **)** virtual
  219. Called for every *key* input event that has not already been handled by another node.
  220. It has to be enabled with :ref:`set_process_unhandled_key_input<class_Node_set_process_unhandled_key_input>` or the corresponding property in the inspector.
  221. .. _class_Node_add_child:
  222. - void **add_child** **(** :ref:`Node<class_node>` node, :ref:`bool<class_bool>` legible_unique_name=false **)**
  223. Add a child :ref:`Node<class_node>`. Nodes can have as many children as they want, but every child must have a unique name. Children nodes are automatically deleted when the parent node is deleted, so deleting a whole scene is performed by deleting its topmost node.
  224. The optional boolean argument enforces creating child nodes with human-readable names, based on the name of the node being instanced instead of its type only.
  225. .. _class_Node_add_to_group:
  226. - void **add_to_group** **(** :ref:`String<class_string>` group, :ref:`bool<class_bool>` persistent=false **)**
  227. Add a node to a group. Groups are helpers to name and organize a subset of nodes, like for example "enemies" or "collectables". A :ref:`Node<class_node>` can be in any number of groups. Nodes can be assigned a group at any time, but will not be added to it until they are inside the scene tree (see :ref:`is_inside_tree<class_Node_is_inside_tree>`).
  228. .. _class_Node_can_process:
  229. - :ref:`bool<class_bool>` **can_process** **(** **)** const
  230. Return true if the node can process, i.e. whether its pause mode allows processing while the scene tree is paused (see :ref:`set_pause_mode<class_Node_set_pause_mode>`). Always returns true if the scene tree is not paused, and false if the node is not in the tree. FIXME: Why FAIL_COND?
  231. .. _class_Node_duplicate:
  232. - :ref:`Node<class_node>` **duplicate** **(** :ref:`bool<class_bool>` use_instancing=false, :ref:`int<class_int>` flags=7 **)** const
  233. Duplicate the node, returning a new :ref:`Node<class_node>`. If ``use_instancing`` is true, the duplicated node will be a new instance of the original :ref:`PackedScene<class_packedscene>`, if not it will be an independent node.
  234. The flags are used to define what attributes (groups, signals, scripts) should be duplicated, as specified by the DUPLICATE\_\* constants. The default value is all of them.
  235. .. _class_Node_find_node:
  236. - :ref:`Node<class_node>` **find_node** **(** :ref:`String<class_string>` mask, :ref:`bool<class_bool>` recursive=true, :ref:`bool<class_bool>` owned=true **)** const
  237. Find a descendant of this node whose name matches ``mask`` as in :ref:`String.match<class_String_match>` (i.e. case sensitive, but '\*' matches zero or more characters and '?' matches any single character except '.'). Note that it does not match against the full path, just against individual node names.
  238. .. _class_Node_get_child:
  239. - :ref:`Node<class_node>` **get_child** **(** :ref:`int<class_int>` idx **)** const
  240. Return a child node by its index (see :ref:`get_child_count<class_Node_get_child_count>`). This method is often used for iterating all children of a node.
  241. .. _class_Node_get_child_count:
  242. - :ref:`int<class_int>` **get_child_count** **(** **)** const
  243. Return the amount of child nodes.
  244. .. _class_Node_get_children:
  245. - :ref:`Array<class_array>` **get_children** **(** **)** const
  246. Return an array of references (:ref:`Node<class_node>`) to the child nodes.
  247. .. _class_Node_get_filename:
  248. - :ref:`String<class_string>` **get_filename** **(** **)** const
  249. Return a filename that may be contained by the node. When a scene is instanced from a file, it topmost node contains the filename from where it was loaded (see :ref:`set_filename<class_Node_set_filename>`).
  250. .. _class_Node_get_fixed_process_delta_time:
  251. - :ref:`float<class_float>` **get_fixed_process_delta_time** **(** **)** const
  252. Return the time elapsed since the last fixed frame (see :ref:`_fixed_process<class_Node__fixed_process>`). This is always the same in fixed processing unless the frames per second is changed in :ref:`OS<class_os>`.
  253. .. _class_Node_get_groups:
  254. - :ref:`Array<class_array>` **get_groups** **(** **)** const
  255. Return an array listing the groups that the node is part of.
  256. .. _class_Node_get_index:
  257. - :ref:`int<class_int>` **get_index** **(** **)** const
  258. Get the node index, i.e. its position among the siblings of its parent.
  259. .. _class_Node_get_name:
  260. - :ref:`String<class_string>` **get_name** **(** **)** const
  261. Return the name of the node. This name is unique among the siblings (other child nodes from the same parent).
  262. .. _class_Node_get_node:
  263. - :ref:`Node<class_node>` **get_node** **(** :ref:`NodePath<class_nodepath>` path **)** const
  264. Fetch a node. The :ref:`NodePath<class_nodepath>` must be valid (or else an error will be raised) and can be either the path to child node, a relative path (from the current node to another node), or an absolute path to a node.
  265. Note: fetching absolute paths only works when the node is inside the scene tree (see :ref:`is_inside_tree<class_Node_is_inside_tree>`).
  266. *Example:* Assume your current node is Character and the following tree:
  267. ::
  268. /root
  269. /root/Character
  270. /root/Character/Sword
  271. /root/Character/Backpack/Dagger
  272. /root/MyGame
  273. /root/Swamp/Alligator
  274. /root/Swamp/Mosquito
  275. /root/Swamp/Goblin
  276. Possible paths are:
  277. ::
  278. get_node("Sword")
  279. get_node("Backpack/Dagger")
  280. get_node("../Swamp/Alligator")
  281. get_node("/root/MyGame")
  282. .. _class_Node_get_node_and_resource:
  283. - :ref:`Array<class_array>` **get_node_and_resource** **(** :ref:`NodePath<class_nodepath>` path **)**
  284. .. _class_Node_get_owner:
  285. - :ref:`Node<class_node>` **get_owner** **(** **)** const
  286. Get the node owner (see :ref:`set_owner<class_Node_set_owner>`).
  287. .. _class_Node_get_parent:
  288. - :ref:`Node<class_node>` **get_parent** **(** **)** const
  289. Return the parent node of the current node, or an empty :ref:`Node<class_node>` if the node lacks a parent.
  290. .. _class_Node_get_path:
  291. - :ref:`NodePath<class_nodepath>` **get_path** **(** **)** const
  292. Return the absolute path of the current node. This only works if the current node is inside the scene tree (see :ref:`is_inside_tree<class_Node_is_inside_tree>`).
  293. .. _class_Node_get_path_to:
  294. - :ref:`NodePath<class_nodepath>` **get_path_to** **(** :ref:`Node<class_node>` node **)** const
  295. Return the relative path from the current node to the specified node in "node" argument. Both nodes must be in the same scene, or else the function will fail.
  296. .. _class_Node_get_pause_mode:
  297. - :ref:`int<class_int>` **get_pause_mode** **(** **)** const
  298. .. _class_Node_get_position_in_parent:
  299. - :ref:`int<class_int>` **get_position_in_parent** **(** **)** const
  300. .. _class_Node_get_process_delta_time:
  301. - :ref:`float<class_float>` **get_process_delta_time** **(** **)** const
  302. Return the time elapsed (in seconds) since the last process callback. This is almost always different each time.
  303. .. _class_Node_get_scene_instance_load_placeholder:
  304. - :ref:`bool<class_bool>` **get_scene_instance_load_placeholder** **(** **)** const
  305. .. _class_Node_get_tree:
  306. - :ref:`SceneTree<class_scenetree>` **get_tree** **(** **)** const
  307. .. _class_Node_get_viewport:
  308. - :ref:`Object<class_object>` **get_viewport** **(** **)** const
  309. .. _class_Node_has_node:
  310. - :ref:`bool<class_bool>` **has_node** **(** :ref:`NodePath<class_nodepath>` path **)** const
  311. .. _class_Node_has_node_and_resource:
  312. - :ref:`bool<class_bool>` **has_node_and_resource** **(** :ref:`NodePath<class_nodepath>` path **)** const
  313. .. _class_Node_is_a_parent_of:
  314. - :ref:`bool<class_bool>` **is_a_parent_of** **(** :ref:`Node<class_node>` node **)** const
  315. Return *true* if the "node" argument is a direct or indirect child of the current node, otherwise return *false*.
  316. .. _class_Node_is_displayed_folded:
  317. - :ref:`bool<class_bool>` **is_displayed_folded** **(** **)** const
  318. .. _class_Node_is_fixed_processing:
  319. - :ref:`bool<class_bool>` **is_fixed_processing** **(** **)** const
  320. Return true if fixed processing is enabled (see :ref:`set_fixed_process<class_Node_set_fixed_process>`).
  321. .. _class_Node_is_greater_than:
  322. - :ref:`bool<class_bool>` **is_greater_than** **(** :ref:`Node<class_node>` node **)** const
  323. Return *true* if "node" occurs later in the scene hierarchy than the current node, otherwise return *false*.
  324. .. _class_Node_is_in_group:
  325. - :ref:`bool<class_bool>` **is_in_group** **(** :ref:`String<class_string>` group **)** const
  326. .. _class_Node_is_inside_tree:
  327. - :ref:`bool<class_bool>` **is_inside_tree** **(** **)** const
  328. .. _class_Node_is_processing:
  329. - :ref:`bool<class_bool>` **is_processing** **(** **)** const
  330. Return whether processing is enabled in the current node (see :ref:`set_process<class_Node_set_process>`).
  331. .. _class_Node_is_processing_input:
  332. - :ref:`bool<class_bool>` **is_processing_input** **(** **)** const
  333. Return true if the node is processing input (see :ref:`set_process_input<class_Node_set_process_input>`).
  334. .. _class_Node_is_processing_unhandled_input:
  335. - :ref:`bool<class_bool>` **is_processing_unhandled_input** **(** **)** const
  336. Return true if the node is processing unhandled input (see :ref:`set_process_unhandled_input<class_Node_set_process_unhandled_input>`).
  337. .. _class_Node_is_processing_unhandled_key_input:
  338. - :ref:`bool<class_bool>` **is_processing_unhandled_key_input** **(** **)** const
  339. .. _class_Node_move_child:
  340. - void **move_child** **(** :ref:`Node<class_node>` child_node, :ref:`int<class_int>` to_pos **)**
  341. Move a child node to a different position (order) amongst the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful.
  342. .. _class_Node_print_stray_nodes:
  343. - void **print_stray_nodes** **(** **)**
  344. .. _class_Node_print_tree:
  345. - void **print_tree** **(** **)**
  346. Print the scene to stdout. Used mainly for debugging purposes.
  347. .. _class_Node_propagate_notification:
  348. - void **propagate_notification** **(** :ref:`int<class_int>` what **)**
  349. Notify the current node and all its children recursively by calling notification() in all of them.
  350. .. _class_Node_queue_free:
  351. - void **queue_free** **(** **)**
  352. .. _class_Node_raise:
  353. - void **raise** **(** **)**
  354. Move this node to the top of the array of nodes of the parent node. This is often useful on GUIs (:ref:`Control<class_control>`), because their order of drawing fully depends on their order in the tree.
  355. .. _class_Node_remove_and_skip:
  356. - void **remove_and_skip** **(** **)**
  357. Remove a node and set all its children as children of the parent node (if exists). All even subscriptions that pass by the removed node will be unsubscribed.
  358. .. _class_Node_remove_child:
  359. - void **remove_child** **(** :ref:`Node<class_node>` node **)**
  360. Remove a child :ref:`Node<class_node>`. Node is NOT deleted and will have to be deleted manually.
  361. .. _class_Node_remove_from_group:
  362. - void **remove_from_group** **(** :ref:`String<class_string>` group **)**
  363. Remove a node from a group.
  364. .. _class_Node_replace_by:
  365. - void **replace_by** **(** :ref:`Node<class_node>` node, :ref:`bool<class_bool>` keep_data=false **)**
  366. Replace a node in a scene by a given one. Subscriptions that pass through this node will be lost.
  367. .. _class_Node_set_display_folded:
  368. - void **set_display_folded** **(** :ref:`bool<class_bool>` fold **)**
  369. .. _class_Node_set_filename:
  370. - void **set_filename** **(** :ref:`String<class_string>` filename **)**
  371. A node can contain a filename. This filename should not be changed by the user, unless writing editors and tools. When a scene is instanced from a file, it topmost node contains the filename from where it was loaded.
  372. .. _class_Node_set_fixed_process:
  373. - void **set_fixed_process** **(** :ref:`bool<class_bool>` enable **)**
  374. Enables or disables node fixed framerate processing. When a node is being processed, it will receive a NOTIFICATION_PROCESS at a fixed (usually 60 fps, check :ref:`OS<class_os>` to change that) interval (and the :ref:`_fixed_process<class_Node__fixed_process>` callback will be called if exists). It is common to check how much time was elapsed since the previous frame by calling :ref:`get_fixed_process_delta_time<class_Node_get_fixed_process_delta_time>`.
  375. .. _class_Node_set_name:
  376. - void **set_name** **(** :ref:`String<class_string>` name **)**
  377. Set the name of the :ref:`Node<class_node>`. Name must be unique within parent, and setting an already existing name will cause for the node to be automatically renamed.
  378. .. _class_Node_set_owner:
  379. - void **set_owner** **(** :ref:`Node<class_node>` owner **)**
  380. Set the node owner. A node can have any other node as owner (as long as a valid parent, grandparent, etc ascending in the tree). When saving a node (using SceneSaver) all the nodes it owns will be saved with it. This allows to create complex SceneTrees, with instancing and subinstancing.
  381. .. _class_Node_set_pause_mode:
  382. - void **set_pause_mode** **(** :ref:`int<class_int>` mode **)**
  383. .. _class_Node_set_process:
  384. - void **set_process** **(** :ref:`bool<class_bool>` enable **)**
  385. Enables or disables node processing. When a node is being processed, it will receive a NOTIFICATION_PROCESS on every drawn frame (and the :ref:`_process<class_Node__process>` callback will be called if exists). It is common to check how much time was elapsed since the previous frame by calling :ref:`get_process_delta_time<class_Node_get_process_delta_time>`.
  386. .. _class_Node_set_process_input:
  387. - void **set_process_input** **(** :ref:`bool<class_bool>` enable **)**
  388. Enable input processing for node. This is not required for GUI controls! It hooks up the node to receive all input (see :ref:`_input<class_Node__input>`).
  389. .. _class_Node_set_process_unhandled_input:
  390. - void **set_process_unhandled_input** **(** :ref:`bool<class_bool>` enable **)**
  391. Enable unhandled input processing for node. This is not required for GUI controls! It hooks up the node to receive all input that was not previously handled before (usually by a :ref:`Control<class_control>`). (see :ref:`_unhandled_input<class_Node__unhandled_input>`).
  392. .. _class_Node_set_process_unhandled_key_input:
  393. - void **set_process_unhandled_key_input** **(** :ref:`bool<class_bool>` enable **)**
  394. .. _class_Node_set_scene_instance_load_placeholder:
  395. - void **set_scene_instance_load_placeholder** **(** :ref:`bool<class_bool>` load_placeholder **)**