class_scenetree.rst 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the SceneTree.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_SceneTree:
  6. SceneTree
  7. =========
  8. **Inherits:** :ref:`MainLoop<class_MainLoop>` **<** :ref:`Object<class_Object>`
  9. Manages the game loop via a hierarchy of nodes.
  10. Description
  11. -----------
  12. As one of the most important classes, the ``SceneTree`` manages the hierarchy of nodes in a scene as well as scenes themselves. Nodes can be added, retrieved and removed. The whole scene tree (and thus the current scene) can be paused. Scenes can be loaded, switched and reloaded.
  13. You can also use the ``SceneTree`` to organize your nodes into groups: every node can be assigned as many groups as you want to create, e.g. a "enemy" group. You can then iterate these groups or even call methods and set properties on all the group's members at once.
  14. ``SceneTree`` is the default :ref:`MainLoop<class_MainLoop>` implementation used by scenes, and is thus in charge of the game loop.
  15. Tutorials
  16. ---------
  17. - :doc:`../getting_started/step_by_step/scene_tree`
  18. - :doc:`../tutorials/viewports/multiple_resolutions`
  19. Properties
  20. ----------
  21. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  22. | :ref:`Node<class_Node>` | :ref:`current_scene<class_SceneTree_property_current_scene>` | |
  23. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`debug_collisions_hint<class_SceneTree_property_debug_collisions_hint>` | ``false`` |
  25. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`debug_navigation_hint<class_SceneTree_property_debug_navigation_hint>` | ``false`` |
  27. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`Node<class_Node>` | :ref:`edited_scene_root<class_SceneTree_property_edited_scene_root>` | |
  29. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  30. | :ref:`MultiplayerAPI<class_MultiplayerAPI>` | :ref:`multiplayer<class_SceneTree_property_multiplayer>` | |
  31. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  32. | :ref:`bool<class_bool>` | :ref:`multiplayer_poll<class_SceneTree_property_multiplayer_poll>` | ``true`` |
  33. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  34. | :ref:`NetworkedMultiplayerPeer<class_NetworkedMultiplayerPeer>` | :ref:`network_peer<class_SceneTree_property_network_peer>` | |
  35. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`paused<class_SceneTree_property_paused>` | ``false`` |
  37. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  38. | :ref:`bool<class_bool>` | :ref:`refuse_new_network_connections<class_SceneTree_property_refuse_new_network_connections>` | ``false`` |
  39. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  40. | :ref:`Viewport<class_Viewport>` | :ref:`root<class_SceneTree_property_root>` | |
  41. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  42. | :ref:`bool<class_bool>` | :ref:`use_font_oversampling<class_SceneTree_property_use_font_oversampling>` | ``false`` |
  43. +-----------------------------------------------------------------+------------------------------------------------------------------------------------------------+-----------+
  44. Methods
  45. -------
  46. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Variant<class_Variant>` | :ref:`call_group<class_SceneTree_method_call_group>` **(** :ref:`String<class_String>` group, :ref:`String<class_String>` method, ... **)** |vararg| |
  48. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Variant<class_Variant>` | :ref:`call_group_flags<class_SceneTree_method_call_group_flags>` **(** :ref:`int<class_int>` flags, :ref:`String<class_String>` group, :ref:`String<class_String>` method, ... **)** |vararg| |
  50. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`change_scene<class_SceneTree_method_change_scene>` **(** :ref:`String<class_String>` path **)** |
  52. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`change_scene_to<class_SceneTree_method_change_scene_to>` **(** :ref:`PackedScene<class_PackedScene>` packed_scene **)** |
  54. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`SceneTreeTimer<class_SceneTreeTimer>` | :ref:`create_timer<class_SceneTree_method_create_timer>` **(** :ref:`float<class_float>` time_sec, :ref:`bool<class_bool>` pause_mode_process=true **)** |
  56. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_frame<class_SceneTree_method_get_frame>` **(** **)** |const| |
  58. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`get_network_connected_peers<class_SceneTree_method_get_network_connected_peers>` **(** **)** |const| |
  60. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`get_network_unique_id<class_SceneTree_method_get_network_unique_id>` **(** **)** |const| |
  62. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`get_node_count<class_SceneTree_method_get_node_count>` **(** **)** |const| |
  64. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Array<class_Array>` | :ref:`get_nodes_in_group<class_SceneTree_method_get_nodes_in_group>` **(** :ref:`String<class_String>` group **)** |
  66. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`int<class_int>` | :ref:`get_rpc_sender_id<class_SceneTree_method_get_rpc_sender_id>` **(** **)** |const| |
  68. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`has_group<class_SceneTree_method_has_group>` **(** :ref:`String<class_String>` name **)** |const| |
  70. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`bool<class_bool>` | :ref:`has_network_peer<class_SceneTree_method_has_network_peer>` **(** **)** |const| |
  72. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_input_handled<class_SceneTree_method_is_input_handled>` **(** **)** |
  74. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_network_server<class_SceneTree_method_is_network_server>` **(** **)** |const| |
  76. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`notify_group<class_SceneTree_method_notify_group>` **(** :ref:`String<class_String>` group, :ref:`int<class_int>` notification **)** |
  78. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`notify_group_flags<class_SceneTree_method_notify_group_flags>` **(** :ref:`int<class_int>` call_flags, :ref:`String<class_String>` group, :ref:`int<class_int>` notification **)** |
  80. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`queue_delete<class_SceneTree_method_queue_delete>` **(** :ref:`Object<class_Object>` obj **)** |
  82. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`quit<class_SceneTree_method_quit>` **(** :ref:`int<class_int>` exit_code=-1 **)** |
  84. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`reload_current_scene<class_SceneTree_method_reload_current_scene>` **(** **)** |
  86. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`set_auto_accept_quit<class_SceneTree_method_set_auto_accept_quit>` **(** :ref:`bool<class_bool>` enabled **)** |
  88. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`set_group<class_SceneTree_method_set_group>` **(** :ref:`String<class_String>` group, :ref:`String<class_String>` property, :ref:`Variant<class_Variant>` value **)** |
  90. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`set_group_flags<class_SceneTree_method_set_group_flags>` **(** :ref:`int<class_int>` call_flags, :ref:`String<class_String>` group, :ref:`String<class_String>` property, :ref:`Variant<class_Variant>` value **)** |
  92. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`set_input_as_handled<class_SceneTree_method_set_input_as_handled>` **(** **)** |
  94. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`set_quit_on_go_back<class_SceneTree_method_set_quit_on_go_back>` **(** :ref:`bool<class_bool>` enabled **)** |
  96. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`set_screen_stretch<class_SceneTree_method_set_screen_stretch>` **(** :ref:`StretchMode<enum_SceneTree_StretchMode>` mode, :ref:`StretchAspect<enum_SceneTree_StretchAspect>` aspect, :ref:`Vector2<class_Vector2>` minsize, :ref:`float<class_float>` shrink=1 **)** |
  98. +---------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. Signals
  100. -------
  101. .. _class_SceneTree_signal_connected_to_server:
  102. - **connected_to_server** **(** **)**
  103. Emitted whenever this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` successfully connected to a server. Only emitted on clients.
  104. ----
  105. .. _class_SceneTree_signal_connection_failed:
  106. - **connection_failed** **(** **)**
  107. Emitted whenever this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` fails to establish a connection to a server. Only emitted on clients.
  108. ----
  109. .. _class_SceneTree_signal_files_dropped:
  110. - **files_dropped** **(** :ref:`PoolStringArray<class_PoolStringArray>` files, :ref:`int<class_int>` screen **)**
  111. Emitted when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated.
  112. ----
  113. .. _class_SceneTree_signal_global_menu_action:
  114. - **global_menu_action** **(** :ref:`Variant<class_Variant>` id, :ref:`Variant<class_Variant>` meta **)**
  115. Emitted whenever global menu item is clicked.
  116. ----
  117. .. _class_SceneTree_signal_idle_frame:
  118. - **idle_frame** **(** **)**
  119. Emitted immediately before :ref:`Node._process<class_Node_method__process>` is called on every node in the ``SceneTree``.
  120. ----
  121. .. _class_SceneTree_signal_network_peer_connected:
  122. - **network_peer_connected** **(** :ref:`int<class_int>` id **)**
  123. Emitted whenever this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` connects with a new peer. ID is the peer ID of the new peer. Clients get notified when other clients connect to the same server. Upon connecting to a server, a client also receives this signal for the server (with ID being 1).
  124. ----
  125. .. _class_SceneTree_signal_network_peer_disconnected:
  126. - **network_peer_disconnected** **(** :ref:`int<class_int>` id **)**
  127. Emitted whenever this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` disconnects from a peer. Clients get notified when other clients disconnect from the same server.
  128. ----
  129. .. _class_SceneTree_signal_node_added:
  130. - **node_added** **(** :ref:`Node<class_Node>` node **)**
  131. Emitted whenever a node is added to the ``SceneTree``.
  132. ----
  133. .. _class_SceneTree_signal_node_configuration_warning_changed:
  134. - **node_configuration_warning_changed** **(** :ref:`Node<class_Node>` node **)**
  135. Emitted when a node's configuration changed. Only emitted in ``tool`` mode.
  136. ----
  137. .. _class_SceneTree_signal_node_removed:
  138. - **node_removed** **(** :ref:`Node<class_Node>` node **)**
  139. Emitted whenever a node is removed from the ``SceneTree``.
  140. ----
  141. .. _class_SceneTree_signal_node_renamed:
  142. - **node_renamed** **(** :ref:`Node<class_Node>` node **)**
  143. Emitted whenever a node is renamed.
  144. ----
  145. .. _class_SceneTree_signal_physics_frame:
  146. - **physics_frame** **(** **)**
  147. Emitted immediately before :ref:`Node._physics_process<class_Node_method__physics_process>` is called on every node in the ``SceneTree``.
  148. ----
  149. .. _class_SceneTree_signal_screen_resized:
  150. - **screen_resized** **(** **)**
  151. Emitted when the screen resolution (fullscreen) or window size (windowed) changes.
  152. ----
  153. .. _class_SceneTree_signal_server_disconnected:
  154. - **server_disconnected** **(** **)**
  155. Emitted whenever this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` disconnected from server. Only emitted on clients.
  156. ----
  157. .. _class_SceneTree_signal_tree_changed:
  158. - **tree_changed** **(** **)**
  159. Emitted whenever the ``SceneTree`` hierarchy changed (children being moved or renamed, etc.).
  160. Enumerations
  161. ------------
  162. .. _enum_SceneTree_GroupCallFlags:
  163. .. _class_SceneTree_constant_GROUP_CALL_DEFAULT:
  164. .. _class_SceneTree_constant_GROUP_CALL_REVERSE:
  165. .. _class_SceneTree_constant_GROUP_CALL_REALTIME:
  166. .. _class_SceneTree_constant_GROUP_CALL_UNIQUE:
  167. enum **GroupCallFlags**:
  168. - **GROUP_CALL_DEFAULT** = **0** --- Call a group with no flags (default).
  169. - **GROUP_CALL_REVERSE** = **1** --- Call a group in reverse scene order.
  170. - **GROUP_CALL_REALTIME** = **2** --- Call a group immediately (calls are normally made on idle).
  171. - **GROUP_CALL_UNIQUE** = **4** --- Call a group only once even if the call is executed many times.
  172. ----
  173. .. _enum_SceneTree_StretchMode:
  174. .. _class_SceneTree_constant_STRETCH_MODE_DISABLED:
  175. .. _class_SceneTree_constant_STRETCH_MODE_2D:
  176. .. _class_SceneTree_constant_STRETCH_MODE_VIEWPORT:
  177. enum **StretchMode**:
  178. - **STRETCH_MODE_DISABLED** = **0** --- No stretching.
  179. - **STRETCH_MODE_2D** = **1** --- Render stretching in higher resolution (interpolated).
  180. - **STRETCH_MODE_VIEWPORT** = **2** --- Keep the specified display resolution. No interpolation. Content may appear pixelated.
  181. ----
  182. .. _enum_SceneTree_StretchAspect:
  183. .. _class_SceneTree_constant_STRETCH_ASPECT_IGNORE:
  184. .. _class_SceneTree_constant_STRETCH_ASPECT_KEEP:
  185. .. _class_SceneTree_constant_STRETCH_ASPECT_KEEP_WIDTH:
  186. .. _class_SceneTree_constant_STRETCH_ASPECT_KEEP_HEIGHT:
  187. .. _class_SceneTree_constant_STRETCH_ASPECT_EXPAND:
  188. enum **StretchAspect**:
  189. - **STRETCH_ASPECT_IGNORE** = **0** --- Fill the window with the content stretched to cover excessive space. Content may appear stretched.
  190. - **STRETCH_ASPECT_KEEP** = **1** --- Retain the same aspect ratio by padding with black bars on either axis. This prevents distortion.
  191. - **STRETCH_ASPECT_KEEP_WIDTH** = **2** --- Expand vertically. Left/right black bars may appear if the window is too wide.
  192. - **STRETCH_ASPECT_KEEP_HEIGHT** = **3** --- Expand horizontally. Top/bottom black bars may appear if the window is too tall.
  193. - **STRETCH_ASPECT_EXPAND** = **4** --- Expand in both directions, retaining the same aspect ratio. This prevents distortion while avoiding black bars.
  194. Property Descriptions
  195. ---------------------
  196. .. _class_SceneTree_property_current_scene:
  197. - :ref:`Node<class_Node>` **current_scene**
  198. +----------+--------------------------+
  199. | *Setter* | set_current_scene(value) |
  200. +----------+--------------------------+
  201. | *Getter* | get_current_scene() |
  202. +----------+--------------------------+
  203. The current scene.
  204. ----
  205. .. _class_SceneTree_property_debug_collisions_hint:
  206. - :ref:`bool<class_bool>` **debug_collisions_hint**
  207. +-----------+----------------------------------+
  208. | *Default* | ``false`` |
  209. +-----------+----------------------------------+
  210. | *Setter* | set_debug_collisions_hint(value) |
  211. +-----------+----------------------------------+
  212. | *Getter* | is_debugging_collisions_hint() |
  213. +-----------+----------------------------------+
  214. If ``true``, collision shapes will be visible when running the game from the editor for debugging purposes.
  215. ----
  216. .. _class_SceneTree_property_debug_navigation_hint:
  217. - :ref:`bool<class_bool>` **debug_navigation_hint**
  218. +-----------+----------------------------------+
  219. | *Default* | ``false`` |
  220. +-----------+----------------------------------+
  221. | *Setter* | set_debug_navigation_hint(value) |
  222. +-----------+----------------------------------+
  223. | *Getter* | is_debugging_navigation_hint() |
  224. +-----------+----------------------------------+
  225. If ``true``, navigation polygons will be visible when running the game from the editor for debugging purposes.
  226. ----
  227. .. _class_SceneTree_property_edited_scene_root:
  228. - :ref:`Node<class_Node>` **edited_scene_root**
  229. +----------+------------------------------+
  230. | *Setter* | set_edited_scene_root(value) |
  231. +----------+------------------------------+
  232. | *Getter* | get_edited_scene_root() |
  233. +----------+------------------------------+
  234. The root of the edited scene.
  235. ----
  236. .. _class_SceneTree_property_multiplayer:
  237. - :ref:`MultiplayerAPI<class_MultiplayerAPI>` **multiplayer**
  238. +----------+------------------------+
  239. | *Setter* | set_multiplayer(value) |
  240. +----------+------------------------+
  241. | *Getter* | get_multiplayer() |
  242. +----------+------------------------+
  243. The default :ref:`MultiplayerAPI<class_MultiplayerAPI>` instance for this ``SceneTree``.
  244. ----
  245. .. _class_SceneTree_property_multiplayer_poll:
  246. - :ref:`bool<class_bool>` **multiplayer_poll**
  247. +-----------+-------------------------------------+
  248. | *Default* | ``true`` |
  249. +-----------+-------------------------------------+
  250. | *Setter* | set_multiplayer_poll_enabled(value) |
  251. +-----------+-------------------------------------+
  252. | *Getter* | is_multiplayer_poll_enabled() |
  253. +-----------+-------------------------------------+
  254. If ``true`` (default value), enables automatic polling of the :ref:`MultiplayerAPI<class_MultiplayerAPI>` for this SceneTree during :ref:`idle_frame<class_SceneTree_signal_idle_frame>`.
  255. If ``false``, you need to manually call :ref:`MultiplayerAPI.poll<class_MultiplayerAPI_method_poll>` to process network packets and deliver RPCs/RSETs. This allows running RPCs/RSETs in a different loop (e.g. physics, thread, specific time step) and for manual :ref:`Mutex<class_Mutex>` protection when accessing the :ref:`MultiplayerAPI<class_MultiplayerAPI>` from threads.
  256. ----
  257. .. _class_SceneTree_property_network_peer:
  258. - :ref:`NetworkedMultiplayerPeer<class_NetworkedMultiplayerPeer>` **network_peer**
  259. +----------+-------------------------+
  260. | *Setter* | set_network_peer(value) |
  261. +----------+-------------------------+
  262. | *Getter* | get_network_peer() |
  263. +----------+-------------------------+
  264. The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the ``SceneTree`` will become a network server (check with :ref:`is_network_server<class_SceneTree_method_is_network_server>`) and will set the root node's network mode to master, or it will become a regular peer with the root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to ``SceneTree``'s signals.
  265. ----
  266. .. _class_SceneTree_property_paused:
  267. - :ref:`bool<class_bool>` **paused**
  268. +-----------+------------------+
  269. | *Default* | ``false`` |
  270. +-----------+------------------+
  271. | *Setter* | set_pause(value) |
  272. +-----------+------------------+
  273. | *Getter* | is_paused() |
  274. +-----------+------------------+
  275. If ``true``, the ``SceneTree`` is paused. Doing so will have the following behavior:
  276. - 2D and 3D physics will be stopped.
  277. - :ref:`Node._process<class_Node_method__process>`, :ref:`Node._physics_process<class_Node_method__physics_process>` and :ref:`Node._input<class_Node_method__input>` will not be called anymore in nodes.
  278. ----
  279. .. _class_SceneTree_property_refuse_new_network_connections:
  280. - :ref:`bool<class_bool>` **refuse_new_network_connections**
  281. +-----------+-------------------------------------------+
  282. | *Default* | ``false`` |
  283. +-----------+-------------------------------------------+
  284. | *Setter* | set_refuse_new_network_connections(value) |
  285. +-----------+-------------------------------------------+
  286. | *Getter* | is_refusing_new_network_connections() |
  287. +-----------+-------------------------------------------+
  288. If ``true``, the ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` refuses new incoming connections.
  289. ----
  290. .. _class_SceneTree_property_root:
  291. - :ref:`Viewport<class_Viewport>` **root**
  292. +----------+------------+
  293. | *Getter* | get_root() |
  294. +----------+------------+
  295. The ``SceneTree``'s root :ref:`Viewport<class_Viewport>`.
  296. ----
  297. .. _class_SceneTree_property_use_font_oversampling:
  298. - :ref:`bool<class_bool>` **use_font_oversampling**
  299. +-----------+----------------------------------+
  300. | *Default* | ``false`` |
  301. +-----------+----------------------------------+
  302. | *Setter* | set_use_font_oversampling(value) |
  303. +-----------+----------------------------------+
  304. | *Getter* | is_using_font_oversampling() |
  305. +-----------+----------------------------------+
  306. If ``true``, font oversampling is used.
  307. Method Descriptions
  308. -------------------
  309. .. _class_SceneTree_method_call_group:
  310. - :ref:`Variant<class_Variant>` **call_group** **(** :ref:`String<class_String>` group, :ref:`String<class_String>` method, ... **)** |vararg|
  311. Calls ``method`` on each member of the given group.
  312. ----
  313. .. _class_SceneTree_method_call_group_flags:
  314. - :ref:`Variant<class_Variant>` **call_group_flags** **(** :ref:`int<class_int>` flags, :ref:`String<class_String>` group, :ref:`String<class_String>` method, ... **)** |vararg|
  315. Calls ``method`` on each member of the given group, respecting the given :ref:`GroupCallFlags<enum_SceneTree_GroupCallFlags>`.
  316. ----
  317. .. _class_SceneTree_method_change_scene:
  318. - :ref:`Error<enum_@GlobalScope_Error>` **change_scene** **(** :ref:`String<class_String>` path **)**
  319. Changes the running scene to the one at the given ``path``, after loading it into a :ref:`PackedScene<class_PackedScene>` and creating a new instance.
  320. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_CANT_OPEN<class_@GlobalScope_constant_ERR_CANT_OPEN>` if the ``path`` cannot be loaded into a :ref:`PackedScene<class_PackedScene>`, or :ref:`@GlobalScope.ERR_CANT_CREATE<class_@GlobalScope_constant_ERR_CANT_CREATE>` if that scene cannot be instantiated.
  321. ----
  322. .. _class_SceneTree_method_change_scene_to:
  323. - :ref:`Error<enum_@GlobalScope_Error>` **change_scene_to** **(** :ref:`PackedScene<class_PackedScene>` packed_scene **)**
  324. Changes the running scene to a new instance of the given :ref:`PackedScene<class_PackedScene>`.
  325. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success or :ref:`@GlobalScope.ERR_CANT_CREATE<class_@GlobalScope_constant_ERR_CANT_CREATE>` if the scene cannot be instantiated.
  326. ----
  327. .. _class_SceneTree_method_create_timer:
  328. - :ref:`SceneTreeTimer<class_SceneTreeTimer>` **create_timer** **(** :ref:`float<class_float>` time_sec, :ref:`bool<class_bool>` pause_mode_process=true **)**
  329. Returns a :ref:`SceneTreeTimer<class_SceneTreeTimer>` which will :ref:`SceneTreeTimer.timeout<class_SceneTreeTimer_signal_timeout>` after the given time in seconds elapsed in this ``SceneTree``. If ``pause_mode_process`` is set to ``false``, pausing the ``SceneTree`` will also pause the timer.
  330. Commonly used to create a one-shot delay timer as in the following example:
  331. ::
  332. func some_function():
  333. print("start")
  334. yield(get_tree().create_timer(1.0), "timeout")
  335. print("end")
  336. ----
  337. .. _class_SceneTree_method_get_frame:
  338. - :ref:`int<class_int>` **get_frame** **(** **)** |const|
  339. Returns the current frame number, i.e. the total frame count since the application started.
  340. ----
  341. .. _class_SceneTree_method_get_network_connected_peers:
  342. - :ref:`PoolIntArray<class_PoolIntArray>` **get_network_connected_peers** **(** **)** |const|
  343. Returns the peer IDs of all connected peers of this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>`.
  344. ----
  345. .. _class_SceneTree_method_get_network_unique_id:
  346. - :ref:`int<class_int>` **get_network_unique_id** **(** **)** |const|
  347. Returns the unique peer ID of this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>`.
  348. ----
  349. .. _class_SceneTree_method_get_node_count:
  350. - :ref:`int<class_int>` **get_node_count** **(** **)** |const|
  351. Returns the number of nodes in this ``SceneTree``.
  352. ----
  353. .. _class_SceneTree_method_get_nodes_in_group:
  354. - :ref:`Array<class_Array>` **get_nodes_in_group** **(** :ref:`String<class_String>` group **)**
  355. Returns a list of all nodes assigned to the given group.
  356. ----
  357. .. _class_SceneTree_method_get_rpc_sender_id:
  358. - :ref:`int<class_int>` **get_rpc_sender_id** **(** **)** |const|
  359. Returns the sender's peer ID for the most recently received RPC call.
  360. ----
  361. .. _class_SceneTree_method_has_group:
  362. - :ref:`bool<class_bool>` **has_group** **(** :ref:`String<class_String>` name **)** |const|
  363. Returns ``true`` if the given group exists.
  364. ----
  365. .. _class_SceneTree_method_has_network_peer:
  366. - :ref:`bool<class_bool>` **has_network_peer** **(** **)** |const|
  367. Returns ``true`` if there is a :ref:`network_peer<class_SceneTree_property_network_peer>` set.
  368. ----
  369. .. _class_SceneTree_method_is_input_handled:
  370. - :ref:`bool<class_bool>` **is_input_handled** **(** **)**
  371. Returns ``true`` if the most recent :ref:`InputEvent<class_InputEvent>` was marked as handled with :ref:`set_input_as_handled<class_SceneTree_method_set_input_as_handled>`.
  372. ----
  373. .. _class_SceneTree_method_is_network_server:
  374. - :ref:`bool<class_bool>` **is_network_server** **(** **)** |const|
  375. Returns ``true`` if this ``SceneTree``'s :ref:`network_peer<class_SceneTree_property_network_peer>` is in server mode (listening for connections).
  376. ----
  377. .. _class_SceneTree_method_notify_group:
  378. - void **notify_group** **(** :ref:`String<class_String>` group, :ref:`int<class_int>` notification **)**
  379. Sends the given notification to all members of the ``group``.
  380. ----
  381. .. _class_SceneTree_method_notify_group_flags:
  382. - void **notify_group_flags** **(** :ref:`int<class_int>` call_flags, :ref:`String<class_String>` group, :ref:`int<class_int>` notification **)**
  383. Sends the given notification to all members of the ``group``, respecting the given :ref:`GroupCallFlags<enum_SceneTree_GroupCallFlags>`.
  384. ----
  385. .. _class_SceneTree_method_queue_delete:
  386. - void **queue_delete** **(** :ref:`Object<class_Object>` obj **)**
  387. Queues the given object for deletion, delaying the call to :ref:`Object.free<class_Object_method_free>` to after the current frame.
  388. ----
  389. .. _class_SceneTree_method_quit:
  390. - void **quit** **(** :ref:`int<class_int>` exit_code=-1 **)**
  391. Quits the application. A process ``exit_code`` can optionally be passed as an argument. If this argument is ``0`` or greater, it will override the :ref:`OS.exit_code<class_OS_property_exit_code>` defined before quitting the application.
  392. ----
  393. .. _class_SceneTree_method_reload_current_scene:
  394. - :ref:`Error<enum_@GlobalScope_Error>` **reload_current_scene** **(** **)**
  395. Reloads the currently active scene.
  396. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_UNCONFIGURED<class_@GlobalScope_constant_ERR_UNCONFIGURED>` if no :ref:`current_scene<class_SceneTree_property_current_scene>` was defined yet, :ref:`@GlobalScope.ERR_CANT_OPEN<class_@GlobalScope_constant_ERR_CANT_OPEN>` if :ref:`current_scene<class_SceneTree_property_current_scene>` cannot be loaded into a :ref:`PackedScene<class_PackedScene>`, or :ref:`@GlobalScope.ERR_CANT_CREATE<class_@GlobalScope_constant_ERR_CANT_CREATE>` if the scene cannot be instantiated.
  397. ----
  398. .. _class_SceneTree_method_set_auto_accept_quit:
  399. - void **set_auto_accept_quit** **(** :ref:`bool<class_bool>` enabled **)**
  400. If ``true``, the application automatically accepts quitting. Enabled by default.
  401. For mobile platforms, see :ref:`set_quit_on_go_back<class_SceneTree_method_set_quit_on_go_back>`.
  402. ----
  403. .. _class_SceneTree_method_set_group:
  404. - void **set_group** **(** :ref:`String<class_String>` group, :ref:`String<class_String>` property, :ref:`Variant<class_Variant>` value **)**
  405. Sets the given ``property`` to ``value`` on all members of the given group.
  406. ----
  407. .. _class_SceneTree_method_set_group_flags:
  408. - void **set_group_flags** **(** :ref:`int<class_int>` call_flags, :ref:`String<class_String>` group, :ref:`String<class_String>` property, :ref:`Variant<class_Variant>` value **)**
  409. Sets the given ``property`` to ``value`` on all members of the given group, respecting the given :ref:`GroupCallFlags<enum_SceneTree_GroupCallFlags>`.
  410. ----
  411. .. _class_SceneTree_method_set_input_as_handled:
  412. - void **set_input_as_handled** **(** **)**
  413. Marks the most recent :ref:`InputEvent<class_InputEvent>` as handled.
  414. ----
  415. .. _class_SceneTree_method_set_quit_on_go_back:
  416. - void **set_quit_on_go_back** **(** :ref:`bool<class_bool>` enabled **)**
  417. If ``true``, the application quits automatically on going back (e.g. on Android). Enabled by default.
  418. To handle 'Go Back' button when this option is disabled, use :ref:`MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST<class_MainLoop_constant_NOTIFICATION_WM_GO_BACK_REQUEST>`.
  419. ----
  420. .. _class_SceneTree_method_set_screen_stretch:
  421. - void **set_screen_stretch** **(** :ref:`StretchMode<enum_SceneTree_StretchMode>` mode, :ref:`StretchAspect<enum_SceneTree_StretchAspect>` aspect, :ref:`Vector2<class_Vector2>` minsize, :ref:`float<class_float>` shrink=1 **)**
  422. Configures screen stretching to the given :ref:`StretchMode<enum_SceneTree_StretchMode>`, :ref:`StretchAspect<enum_SceneTree_StretchAspect>`, minimum size and ``shrink`` ratio.
  423. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  424. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  425. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`