mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
3203 lines
200 KiB
ReStructuredText
3203 lines
200 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. _class_Node:
|
||
|
||
Node
|
||
====
|
||
|
||
**繼承:** :ref:`Object<class_Object>`
|
||
|
||
**被繼承:** :ref:`AnimationMixer<class_AnimationMixer>`, :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`, :ref:`CanvasItem<class_CanvasItem>`, :ref:`CanvasLayer<class_CanvasLayer>`, :ref:`EditorFileSystem<class_EditorFileSystem>`, :ref:`EditorPlugin<class_EditorPlugin>`, :ref:`EditorResourcePreview<class_EditorResourcePreview>`, :ref:`HTTPRequest<class_HTTPRequest>`, :ref:`InstancePlaceholder<class_InstancePlaceholder>`, :ref:`MissingNode<class_MissingNode>`, :ref:`MultiplayerSpawner<class_MultiplayerSpawner>`, :ref:`MultiplayerSynchronizer<class_MultiplayerSynchronizer>`, :ref:`NavigationAgent2D<class_NavigationAgent2D>`, :ref:`NavigationAgent3D<class_NavigationAgent3D>`, :ref:`Node3D<class_Node3D>`, :ref:`ResourcePreloader<class_ResourcePreloader>`, :ref:`ShaderGlobalsOverride<class_ShaderGlobalsOverride>`, :ref:`StatusIndicator<class_StatusIndicator>`, :ref:`Timer<class_Timer>`, :ref:`Viewport<class_Viewport>`, :ref:`WorldEnvironment<class_WorldEnvironment>`
|
||
|
||
所有場景物件的基底類別。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
說明
|
||
----
|
||
|
||
節點是 Godot 的基礎組件。每個節點可被指定為另一個節點的子節點,形成樹狀結構。每個節點可包含任意數量的子節點,但所有兄弟節點(同一父節點的直接子節點)必須具備唯一名稱。
|
||
|
||
節點組成的樹稱為\ *場景*\ 。場景可儲存至磁碟,再實體化加入其他場景。這讓 Godot 專案的架構和資料模型更具彈性。
|
||
|
||
\ **場景樹:**\ :ref:`SceneTree<class_SceneTree>` 管理目前啟動的節點樹。當節點被加入場景樹時,會收到 :ref:`NOTIFICATION_ENTER_TREE<class_Node_constant_NOTIFICATION_ENTER_TREE>` 通知,並觸發其 :ref:`_enter_tree()<class_Node_private_method__enter_tree>` 回呼。子節點一定在父節點\ *之後*\ 加入,也就是說父節點的 :ref:`_enter_tree()<class_Node_private_method__enter_tree>` 會先於子節點被呼叫。
|
||
|
||
當所有節點都已加入場景樹時,會收到 :ref:`NOTIFICATION_READY<class_Node_constant_NOTIFICATION_READY>` 通知,對應的 :ref:`_ready()<class_Node_private_method__ready>` 回呼會被觸發。對於一組節點,\ :ref:`_ready()<class_Node_private_method__ready>` 會先從子節點開始,再往上到父節點(反向順序)。
|
||
|
||
這代表節點加入場景樹時,回呼順序為:父節點的 :ref:`_enter_tree()<class_Node_private_method__enter_tree>`\ 、子節點的 :ref:`_enter_tree()<class_Node_private_method__enter_tree>`\ 、子節點的 :ref:`_ready()<class_Node_private_method__ready>`\ ,最後是父節點的 :ref:`_ready()<class_Node_private_method__ready>`\ (整個場景樹遞迴執行)。
|
||
|
||
\ **處理流程:**\ 節點可覆寫「處理」狀態,每個影格都會收到回呼請求進行處理。一般處理(\ :ref:`_process()<class_Node_private_method__process>`\ ,可用 :ref:`set_process()<class_Node_method_set_process>` 切換)會盡可能快執行,並視影格率而定,因此 *delta*\ (秒)會傳入作為參數。物理處理(\ :ref:`_physics_process()<class_Node_private_method__physics_process>`\ ,可用 :ref:`set_physics_process()<class_Node_method_set_physics_process>` 切換)每秒會固定次數執行(預設 60 次),適用於處理物理相關程式。
|
||
|
||
節點也可處理輸入事件。若有 :ref:`_input()<class_Node_private_method__input>` 函式,收到輸入時會呼叫它。多數情況下這可能過於頻繁(除非專案很簡單),可使用 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>`\ ,只有當事件沒被其他節點(通常是 :ref:`Control<class_Control>` 類 GUI 節點)處理時才會呼叫,確保節點僅收到該屬於它的事件。
|
||
|
||
為了追蹤場景階層(特別是場景嵌入場景時),可用 :ref:`owner<class_Node_property_owner>` 屬性為節點設定「擁有者」,記錄誰產生了哪些實體。這在開發編輯器或工具時尤為有用。
|
||
|
||
最後,當節點被 :ref:`Object.free()<class_Object_method_free>` 或 :ref:`queue_free()<class_Node_method_queue_free>` 釋放時,會連同所有子節點一併釋放。
|
||
|
||
\ **群組:**\ 節點可加入任意多個群組以便管理,例如可依遊戲需求建立「敵人」或「可收集物」等群組。參見 :ref:`add_to_group()<class_Node_method_add_to_group>`\ 、\ :ref:`is_in_group()<class_Node_method_is_in_group>`\ 、\ :ref:`remove_from_group()<class_Node_method_remove_from_group>`\ 。你可取得群組內所有節點、遍歷或批次呼叫群組方法(透過 :ref:`SceneTree<class_SceneTree>`\ )。
|
||
|
||
\ **節點網路功能:**\ 連線到伺服器(或自行架設,見 :ref:`ENetMultiplayerPeer<class_ENetMultiplayerPeer>`\ )後,可利用內建 RPC(遠端程式呼叫)系統進行網路通訊。只需用 :ref:`rpc()<class_Node_method_rpc>` 呼叫方法名稱,即會在本地與所有連線端執行該方法(連線端=用戶端與接受連線之伺服器)。Godot 會用 :ref:`NodePath<class_NodePath>` 來辨識接收 RPC 呼叫的節點(請確保所有端的節點名稱一致)。亦可參閱高階網路教學與範例。
|
||
|
||
\ **注意:**\ ``script`` 屬性屬於 :ref:`Object<class_Object>` 類,不屬於 **Node**\ 。它不像大多數屬性那樣公開,但有 setter 與 getter(見 :ref:`Object.set_script()<class_Object_method_set_script>`\ 、\ :ref:`Object.get_script()<class_Object_method_get_script>`\ )。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
教學
|
||
----
|
||
|
||
- :doc:`節點與場景 <../getting_started/step_by_step/nodes_and_scenes>`
|
||
|
||
- `所有範例 <https://github.com/godotengine/godot-demo-projects/>`__
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
屬性
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>` | :ref:`auto_translate_mode<class_Node_property_auto_translate_mode>` | ``0`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`String<class_String>` | :ref:`editor_description<class_Node_property_editor_description>` | ``""`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`MultiplayerAPI<class_MultiplayerAPI>` | :ref:`multiplayer<class_Node_property_multiplayer>` | |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`StringName<class_StringName>` | :ref:`name<class_Node_property_name>` | |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`Node<class_Node>` | :ref:`owner<class_Node_property_owner>` | |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` | :ref:`physics_interpolation_mode<class_Node_property_physics_interpolation_mode>` | ``0`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`ProcessMode<enum_Node_ProcessMode>` | :ref:`process_mode<class_Node_property_process_mode>` | ``0`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`int<class_int>` | :ref:`process_physics_priority<class_Node_property_process_physics_priority>` | ``0`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`int<class_int>` | :ref:`process_priority<class_Node_property_process_priority>` | ``0`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>` | :ref:`process_thread_group<class_Node_property_process_thread_group>` | ``0`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`int<class_int>` | :ref:`process_thread_group_order<class_Node_property_process_thread_group_order>` | |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| |bitfield|\[:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>`\] | :ref:`process_thread_messages<class_Node_property_process_thread_messages>` | |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`String<class_String>` | :ref:`scene_file_path<class_Node_property_scene_file_path>` | |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
| :ref:`bool<class_bool>` | :ref:`unique_name_in_owner<class_Node_property_unique_name_in_owner>` | ``false`` |
|
||
+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
方法
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_enter_tree<class_Node_private_method__enter_tree>`\ (\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_exit_tree<class_Node_private_method__exit_tree>`\ (\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`_get_accessibility_configuration_warnings<class_Node_private_method__get_accessibility_configuration_warnings>`\ (\ ) |virtual| |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`_get_configuration_warnings<class_Node_private_method__get_configuration_warnings>`\ (\ ) |virtual| |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`RID<class_RID>` | :ref:`_get_focused_accessibility_element<class_Node_private_method__get_focused_accessibility_element>`\ (\ ) |virtual| |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_input<class_Node_private_method__input>`\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_physics_process<class_Node_private_method__physics_process>`\ (\ delta\: :ref:`float<class_float>`\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_process<class_Node_private_method__process>`\ (\ delta\: :ref:`float<class_float>`\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_ready<class_Node_private_method__ready>`\ (\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_shortcut_input<class_Node_private_method__shortcut_input>`\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_unhandled_input<class_Node_private_method__unhandled_input>`\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_unhandled_key_input<class_Node_private_method__unhandled_key_input>`\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_child<class_Node_method_add_child>`\ (\ node\: :ref:`Node<class_Node>`, force_readable_name\: :ref:`bool<class_bool>` = false, internal\: :ref:`InternalMode<enum_Node_InternalMode>` = 0\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_sibling<class_Node_method_add_sibling>`\ (\ sibling\: :ref:`Node<class_Node>`, force_readable_name\: :ref:`bool<class_bool>` = false\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_to_group<class_Node_method_add_to_group>`\ (\ group\: :ref:`StringName<class_StringName>`, persistent\: :ref:`bool<class_bool>` = false\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`atr<class_Node_method_atr>`\ (\ message\: :ref:`String<class_String>`, context\: :ref:`StringName<class_StringName>` = ""\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`atr_n<class_Node_method_atr_n>`\ (\ message\: :ref:`String<class_String>`, plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = ""\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Variant<class_Variant>` | :ref:`call_deferred_thread_group<class_Node_method_call_deferred_thread_group>`\ (\ method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Variant<class_Variant>` | :ref:`call_thread_safe<class_Node_method_call_thread_safe>`\ (\ method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`can_auto_translate<class_Node_method_can_auto_translate>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`can_process<class_Node_method_can_process>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Tween<class_Tween>` | :ref:`create_tween<class_Node_method_create_tween>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`duplicate<class_Node_method_duplicate>`\ (\ flags\: :ref:`int<class_int>` = 15\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`find_child<class_Node_method_find_child>`\ (\ pattern\: :ref:`String<class_String>`, recursive\: :ref:`bool<class_bool>` = true, owned\: :ref:`bool<class_bool>` = true\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>`\[:ref:`Node<class_Node>`\] | :ref:`find_children<class_Node_method_find_children>`\ (\ pattern\: :ref:`String<class_String>`, type\: :ref:`String<class_String>` = "", recursive\: :ref:`bool<class_bool>` = true, owned\: :ref:`bool<class_bool>` = true\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`find_parent<class_Node_method_find_parent>`\ (\ pattern\: :ref:`String<class_String>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`RID<class_RID>` | :ref:`get_accessibility_element<class_Node_method_get_accessibility_element>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`get_child<class_Node_method_get_child>`\ (\ idx\: :ref:`int<class_int>`, include_internal\: :ref:`bool<class_bool>` = false\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_child_count<class_Node_method_get_child_count>`\ (\ include_internal\: :ref:`bool<class_bool>` = false\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>`\[:ref:`Node<class_Node>`\] | :ref:`get_children<class_Node_method_get_children>`\ (\ include_internal\: :ref:`bool<class_bool>` = false\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] | :ref:`get_groups<class_Node_method_get_groups>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_index<class_Node_method_get_index>`\ (\ include_internal\: :ref:`bool<class_bool>` = false\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Window<class_Window>` | :ref:`get_last_exclusive_window<class_Node_method_get_last_exclusive_window>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_multiplayer_authority<class_Node_method_get_multiplayer_authority>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`get_node<class_Node_method_get_node>`\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>` | :ref:`get_node_and_resource<class_Node_method_get_node_and_resource>`\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`get_node_or_null<class_Node_method_get_node_or_null>`\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Variant<class_Variant>` | :ref:`get_node_rpc_config<class_Node_method_get_node_rpc_config>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>`\[:ref:`int<class_int>`\] | :ref:`get_orphan_node_ids<class_Node_method_get_orphan_node_ids>`\ (\ ) |static| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`get_parent<class_Node_method_get_parent>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`get_path<class_Node_method_get_path>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`get_path_to<class_Node_method_get_path_to>`\ (\ node\: :ref:`Node<class_Node>`, use_unique_path\: :ref:`bool<class_bool>` = false\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_physics_process_delta_time<class_Node_method_get_physics_process_delta_time>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_process_delta_time<class_Node_method_get_process_delta_time>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`get_scene_instance_load_placeholder<class_Node_method_get_scene_instance_load_placeholder>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`SceneTree<class_SceneTree>` | :ref:`get_tree<class_Node_method_get_tree>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`get_tree_string<class_Node_method_get_tree_string>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`get_tree_string_pretty<class_Node_method_get_tree_string_pretty>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Viewport<class_Viewport>` | :ref:`get_viewport<class_Node_method_get_viewport>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Window<class_Window>` | :ref:`get_window<class_Node_method_get_window>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_node<class_Node_method_has_node>`\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_node_and_resource<class_Node_method_has_node_and_resource>`\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_ancestor_of<class_Node_method_is_ancestor_of>`\ (\ node\: :ref:`Node<class_Node>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_displayed_folded<class_Node_method_is_displayed_folded>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_editable_instance<class_Node_method_is_editable_instance>`\ (\ node\: :ref:`Node<class_Node>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_greater_than<class_Node_method_is_greater_than>`\ (\ node\: :ref:`Node<class_Node>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_in_group<class_Node_method_is_in_group>`\ (\ group\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_inside_tree<class_Node_method_is_inside_tree>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_multiplayer_authority<class_Node_method_is_multiplayer_authority>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_node_ready<class_Node_method_is_node_ready>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_part_of_edited_scene<class_Node_method_is_part_of_edited_scene>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_physics_interpolated<class_Node_method_is_physics_interpolated>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_physics_interpolated_and_enabled<class_Node_method_is_physics_interpolated_and_enabled>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_physics_processing<class_Node_method_is_physics_processing>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_physics_processing_internal<class_Node_method_is_physics_processing_internal>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_processing<class_Node_method_is_processing>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_processing_input<class_Node_method_is_processing_input>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_processing_internal<class_Node_method_is_processing_internal>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_processing_shortcut_input<class_Node_method_is_processing_shortcut_input>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_processing_unhandled_input<class_Node_method_is_processing_unhandled_input>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_processing_unhandled_key_input<class_Node_method_is_processing_unhandled_key_input>`\ (\ ) |const| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`move_child<class_Node_method_move_child>`\ (\ child_node\: :ref:`Node<class_Node>`, to_index\: :ref:`int<class_int>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`notify_deferred_thread_group<class_Node_method_notify_deferred_thread_group>`\ (\ what\: :ref:`int<class_int>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`notify_thread_safe<class_Node_method_notify_thread_safe>`\ (\ what\: :ref:`int<class_int>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`print_orphan_nodes<class_Node_method_print_orphan_nodes>`\ (\ ) |static| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`print_tree<class_Node_method_print_tree>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`print_tree_pretty<class_Node_method_print_tree_pretty>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`propagate_call<class_Node_method_propagate_call>`\ (\ method\: :ref:`StringName<class_StringName>`, args\: :ref:`Array<class_Array>` = [], parent_first\: :ref:`bool<class_bool>` = false\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`propagate_notification<class_Node_method_propagate_notification>`\ (\ what\: :ref:`int<class_int>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`queue_accessibility_update<class_Node_method_queue_accessibility_update>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`queue_free<class_Node_method_queue_free>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_child<class_Node_method_remove_child>`\ (\ node\: :ref:`Node<class_Node>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_from_group<class_Node_method_remove_from_group>`\ (\ group\: :ref:`StringName<class_StringName>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`reparent<class_Node_method_reparent>`\ (\ new_parent\: :ref:`Node<class_Node>`, keep_global_transform\: :ref:`bool<class_bool>` = true\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`replace_by<class_Node_method_replace_by>`\ (\ node\: :ref:`Node<class_Node>`, keep_groups\: :ref:`bool<class_bool>` = false\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`request_ready<class_Node_method_request_ready>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`reset_physics_interpolation<class_Node_method_reset_physics_interpolation>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`rpc<class_Node_method_rpc>`\ (\ method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`rpc_config<class_Node_method_rpc_config>`\ (\ method\: :ref:`StringName<class_StringName>`, config\: :ref:`Variant<class_Variant>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`rpc_id<class_Node_method_rpc_id>`\ (\ peer_id\: :ref:`int<class_int>`, method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_deferred_thread_group<class_Node_method_set_deferred_thread_group>`\ (\ property\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_display_folded<class_Node_method_set_display_folded>`\ (\ fold\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_editable_instance<class_Node_method_set_editable_instance>`\ (\ node\: :ref:`Node<class_Node>`, is_editable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_multiplayer_authority<class_Node_method_set_multiplayer_authority>`\ (\ id\: :ref:`int<class_int>`, recursive\: :ref:`bool<class_bool>` = true\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_physics_process<class_Node_method_set_physics_process>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_physics_process_internal<class_Node_method_set_physics_process_internal>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_process<class_Node_method_set_process>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_process_input<class_Node_method_set_process_input>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_process_internal<class_Node_method_set_process_internal>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_process_shortcut_input<class_Node_method_set_process_shortcut_input>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_process_unhandled_input<class_Node_method_set_process_unhandled_input>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_process_unhandled_key_input<class_Node_method_set_process_unhandled_key_input>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_scene_instance_load_placeholder<class_Node_method_set_scene_instance_load_placeholder>`\ (\ load_placeholder\: :ref:`bool<class_bool>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_thread_safe<class_Node_method_set_thread_safe>`\ (\ property\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_translation_domain_inherited<class_Node_method_set_translation_domain_inherited>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`update_configuration_warnings<class_Node_method_update_configuration_warnings>`\ (\ ) |
|
||
+------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
訊號
|
||
----
|
||
|
||
.. _class_Node_signal_child_entered_tree:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**child_entered_tree**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_Node_signal_child_entered_tree>`
|
||
|
||
當子 ``node`` 進入 :ref:`SceneTree<class_SceneTree>` 時發出,通常是因本節點進入樹(見 :ref:`tree_entered<class_Node_signal_tree_entered>`\ ),或呼叫 :ref:`add_child()<class_Node_method_add_child>`\ 。
|
||
|
||
此訊號會在子節點自己的 :ref:`NOTIFICATION_ENTER_TREE<class_Node_constant_NOTIFICATION_ENTER_TREE>` 與 :ref:`tree_entered<class_Node_signal_tree_entered>`\ *之後*\ 發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_child_exiting_tree:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**child_exiting_tree**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_Node_signal_child_exiting_tree>`
|
||
|
||
當子 ``node`` 即將離開 :ref:`SceneTree<class_SceneTree>` 時發出,通常是因本節點離開樹(見 :ref:`tree_exiting<class_Node_signal_tree_exiting>`\ ),或子 ``node`` 被移除或釋放。
|
||
|
||
收到本訊號時,子 ``node`` 仍可於樹中存取。本訊號會在子節點自己的 :ref:`tree_exiting<class_Node_signal_tree_exiting>` 與 :ref:`NOTIFICATION_EXIT_TREE<class_Node_constant_NOTIFICATION_EXIT_TREE>`\ *之後*\ 發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_child_order_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**child_order_changed**\ (\ ) :ref:`🔗<class_Node_signal_child_order_changed>`
|
||
|
||
子節點列表異動時發出。包含新增、移動或移除子節點時。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_editor_description_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**editor_description_changed**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_Node_signal_editor_description_changed>`
|
||
|
||
當節點的編輯器描述欄被更動時發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_editor_state_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**editor_state_changed**\ (\ ) :ref:`🔗<class_Node_signal_editor_state_changed>`
|
||
|
||
當與編輯器相關的節點屬性變更時發出。僅於編輯器內發射。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_ready:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**ready**\ (\ ) :ref:`🔗<class_Node_signal_ready>`
|
||
|
||
當節點就緒並執行完 :ref:`_ready()<class_Node_private_method__ready>` 後發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_renamed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**renamed**\ (\ ) :ref:`🔗<class_Node_signal_renamed>`
|
||
|
||
當節點的 :ref:`name<class_Node_property_name>` 於樹中被更改時發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_replacing_by:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**replacing_by**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_Node_signal_replacing_by>`
|
||
|
||
當本節點被 ``node`` 取代時發出,詳見 :ref:`replace_by()<class_Node_method_replace_by>`\ 。
|
||
|
||
此訊號於 ``node`` 已被加入原父節點作為子節點\ *之後*\ ,但原所有子節點重新設為 ``node`` 的子節點\ *之前*\ 發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_tree_entered:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**tree_entered**\ (\ ) :ref:`🔗<class_Node_signal_tree_entered>`
|
||
|
||
當節點進入樹時發出。
|
||
|
||
本訊號於相關 :ref:`NOTIFICATION_ENTER_TREE<class_Node_constant_NOTIFICATION_ENTER_TREE>` 通知\ *之後*\ 發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_tree_exited:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**tree_exited**\ (\ ) :ref:`🔗<class_Node_signal_tree_exited>`
|
||
|
||
當節點離開樹且不再有效時發出。
|
||
|
||
本訊號於相關 :ref:`NOTIFICATION_EXIT_TREE<class_Node_constant_NOTIFICATION_EXIT_TREE>` 通知\ *之後*\ 發出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_signal_tree_exiting:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**tree_exiting**\ (\ ) :ref:`🔗<class_Node_signal_tree_exiting>`
|
||
|
||
當節點即將離開樹時發出,此時節點仍有效。適合在此進行反初始化(如同「解構函式」)。
|
||
|
||
該訊號於節點的 :ref:`_exit_tree()<class_Node_private_method__exit_tree>`\ *之後*\ ,且相關 :ref:`NOTIFICATION_EXIT_TREE<class_Node_constant_NOTIFICATION_EXIT_TREE>`\ *之前*\ 發出。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
列舉
|
||
----
|
||
|
||
.. _enum_Node_ProcessMode:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **ProcessMode**: :ref:`🔗<enum_Node_ProcessMode>`
|
||
|
||
.. _class_Node_constant_PROCESS_MODE_INHERIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessMode<enum_Node_ProcessMode>` **PROCESS_MODE_INHERIT** = ``0``
|
||
|
||
繼承父節點的 :ref:`process_mode<class_Node_property_process_mode>`\ 。這是新建立節點的預設值。
|
||
|
||
.. _class_Node_constant_PROCESS_MODE_PAUSABLE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessMode<enum_Node_ProcessMode>` **PROCESS_MODE_PAUSABLE** = ``1``
|
||
|
||
當 :ref:`SceneTree.paused<class_SceneTree_property_paused>` 為 ``true`` 時停止處理。這是 :ref:`PROCESS_MODE_WHEN_PAUSED<class_Node_constant_PROCESS_MODE_WHEN_PAUSED>` 的相反,並且是根節點的預設值。
|
||
|
||
.. _class_Node_constant_PROCESS_MODE_WHEN_PAUSED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessMode<enum_Node_ProcessMode>` **PROCESS_MODE_WHEN_PAUSED** = ``2``
|
||
|
||
僅在 :ref:`SceneTree.paused<class_SceneTree_property_paused>` 為 ``true`` 時\ **才**\ 處理。這是 :ref:`PROCESS_MODE_PAUSABLE<class_Node_constant_PROCESS_MODE_PAUSABLE>` 的相反。
|
||
|
||
.. _class_Node_constant_PROCESS_MODE_ALWAYS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessMode<enum_Node_ProcessMode>` **PROCESS_MODE_ALWAYS** = ``3``
|
||
|
||
總是處理。無視 :ref:`SceneTree.paused<class_SceneTree_property_paused>`\ ,持續處理。這是 :ref:`PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>` 的相反。
|
||
|
||
.. _class_Node_constant_PROCESS_MODE_DISABLED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessMode<enum_Node_ProcessMode>` **PROCESS_MODE_DISABLED** = ``4``
|
||
|
||
從不處理。完全禁用處理,無視 :ref:`SceneTree.paused<class_SceneTree_property_paused>`\ 。這是 :ref:`PROCESS_MODE_ALWAYS<class_Node_constant_PROCESS_MODE_ALWAYS>` 的相反。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Node_ProcessThreadGroup:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **ProcessThreadGroup**: :ref:`🔗<enum_Node_ProcessThreadGroup>`
|
||
|
||
.. _class_Node_constant_PROCESS_THREAD_GROUP_INHERIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>` **PROCESS_THREAD_GROUP_INHERIT** = ``0``
|
||
|
||
根據第一個(或祖父)非繼承執行緒組模式的父節點處理此節點。詳情請見 :ref:`process_thread_group<class_Node_property_process_thread_group>`\ 。
|
||
|
||
.. _class_Node_constant_PROCESS_THREAD_GROUP_MAIN_THREAD:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>` **PROCESS_THREAD_GROUP_MAIN_THREAD** = ``1``
|
||
|
||
於主執行緒上處理此節點(以及設為繼承的子節點)。詳情請見 :ref:`process_thread_group<class_Node_property_process_thread_group>`\ 。
|
||
|
||
.. _class_Node_constant_PROCESS_THREAD_GROUP_SUB_THREAD:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>` **PROCESS_THREAD_GROUP_SUB_THREAD** = ``2``
|
||
|
||
於子執行緒上處理此節點(以及設為繼承的子節點)。詳情請見 :ref:`process_thread_group<class_Node_property_process_thread_group>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Node_ProcessThreadMessages:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
flags **ProcessThreadMessages**: :ref:`🔗<enum_Node_ProcessThreadMessages>`
|
||
|
||
.. _class_Node_constant_FLAG_PROCESS_THREAD_MESSAGES:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>` **FLAG_PROCESS_THREAD_MESSAGES** = ``1``
|
||
|
||
允許此節點在呼叫 :ref:`_process()<class_Node_private_method__process>` 前,處理以 :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>` 建立的執行緒訊息。
|
||
|
||
.. _class_Node_constant_FLAG_PROCESS_THREAD_MESSAGES_PHYSICS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>` **FLAG_PROCESS_THREAD_MESSAGES_PHYSICS** = ``2``
|
||
|
||
允許此節點在呼叫 :ref:`_physics_process()<class_Node_private_method__physics_process>` 前,處理以 :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>` 建立的執行緒訊息。
|
||
|
||
.. _class_Node_constant_FLAG_PROCESS_THREAD_MESSAGES_ALL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>` **FLAG_PROCESS_THREAD_MESSAGES_ALL** = ``3``
|
||
|
||
允許此節點在呼叫 :ref:`_process()<class_Node_private_method__process>` 或 :ref:`_physics_process()<class_Node_private_method__physics_process>` 之前處理以 :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>` 建立的執行緒訊息。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Node_PhysicsInterpolationMode:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **PhysicsInterpolationMode**: :ref:`🔗<enum_Node_PhysicsInterpolationMode>`
|
||
|
||
.. _class_Node_constant_PHYSICS_INTERPOLATION_MODE_INHERIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` **PHYSICS_INTERPOLATION_MODE_INHERIT** = ``0``
|
||
|
||
繼承父節點的 :ref:`physics_interpolation_mode<class_Node_property_physics_interpolation_mode>`\ 。這是新建立節點的預設值。
|
||
|
||
.. _class_Node_constant_PHYSICS_INTERPOLATION_MODE_ON:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` **PHYSICS_INTERPOLATION_MODE_ON** = ``1``
|
||
|
||
啟用此節點及設為 :ref:`PHYSICS_INTERPOLATION_MODE_INHERIT<class_Node_constant_PHYSICS_INTERPOLATION_MODE_INHERIT>` 子節點的物理內插。這是根節點的預設值。
|
||
|
||
.. _class_Node_constant_PHYSICS_INTERPOLATION_MODE_OFF:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` **PHYSICS_INTERPOLATION_MODE_OFF** = ``2``
|
||
|
||
停用此節點及設為 :ref:`PHYSICS_INTERPOLATION_MODE_INHERIT<class_Node_constant_PHYSICS_INTERPOLATION_MODE_INHERIT>` 子節點的物理內插。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Node_DuplicateFlags:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **DuplicateFlags**: :ref:`🔗<enum_Node_DuplicateFlags>`
|
||
|
||
.. _class_Node_constant_DUPLICATE_SIGNALS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DuplicateFlags<enum_Node_DuplicateFlags>` **DUPLICATE_SIGNALS** = ``1``
|
||
|
||
Duplicate the node's signal connections that are connected with the :ref:`Object.CONNECT_PERSIST<class_Object_constant_CONNECT_PERSIST>` flag.
|
||
|
||
.. _class_Node_constant_DUPLICATE_GROUPS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DuplicateFlags<enum_Node_DuplicateFlags>` **DUPLICATE_GROUPS** = ``2``
|
||
|
||
複製節點的群組。
|
||
|
||
.. _class_Node_constant_DUPLICATE_SCRIPTS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DuplicateFlags<enum_Node_DuplicateFlags>` **DUPLICATE_SCRIPTS** = ``4``
|
||
|
||
複製節點的腳本(如與 :ref:`DUPLICATE_USE_INSTANTIATION<class_Node_constant_DUPLICATE_USE_INSTANTIATION>` 一同使用,也會覆蓋複製子節點的腳本)。
|
||
|
||
.. _class_Node_constant_DUPLICATE_USE_INSTANTIATION:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DuplicateFlags<enum_Node_DuplicateFlags>` **DUPLICATE_USE_INSTANTIATION** = ``8``
|
||
|
||
以 :ref:`PackedScene.instantiate()<class_PackedScene_method_instantiate>` 進行複製。若節點來自儲存於磁碟的場景,會以 :ref:`PackedScene.instantiate()<class_PackedScene_method_instantiate>` 作為複製節點及其子節點的基礎。
|
||
|
||
.. _class_Node_constant_DUPLICATE_INTERNAL_STATE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DuplicateFlags<enum_Node_DuplicateFlags>` **DUPLICATE_INTERNAL_STATE** = ``16``
|
||
|
||
Duplicate also non-serializable variables (i.e. without :ref:`@GlobalScope.PROPERTY_USAGE_STORAGE<class_@GlobalScope_constant_PROPERTY_USAGE_STORAGE>`).
|
||
|
||
.. _class_Node_constant_DUPLICATE_DEFAULT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DuplicateFlags<enum_Node_DuplicateFlags>` **DUPLICATE_DEFAULT** = ``15``
|
||
|
||
Duplicate using default flags. This constant is useful to add or remove a single flag.
|
||
|
||
::
|
||
|
||
# Duplicate non-exported variables.
|
||
var dupe = duplicate(DUPLICATE_DEFAULT | DUPLICATE_INTERNAL_STATE)
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Node_InternalMode:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **InternalMode**: :ref:`🔗<enum_Node_InternalMode>`
|
||
|
||
.. _class_Node_constant_INTERNAL_MODE_DISABLED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`InternalMode<enum_Node_InternalMode>` **INTERNAL_MODE_DISABLED** = ``0``
|
||
|
||
此節點不會設為內部節點。
|
||
|
||
.. _class_Node_constant_INTERNAL_MODE_FRONT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`InternalMode<enum_Node_InternalMode>` **INTERNAL_MODE_FRONT** = ``1``
|
||
|
||
此節點將被放置於父節點的子節點列表開頭,位於所有非內部兄弟節點之前。
|
||
|
||
.. _class_Node_constant_INTERNAL_MODE_BACK:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`InternalMode<enum_Node_InternalMode>` **INTERNAL_MODE_BACK** = ``2``
|
||
|
||
此節點將被放置於父節點的子節點列表末尾,位於所有非內部兄弟節點之後。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Node_AutoTranslateMode:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **AutoTranslateMode**: :ref:`🔗<enum_Node_AutoTranslateMode>`
|
||
|
||
.. _class_Node_constant_AUTO_TRANSLATE_MODE_INHERIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>` **AUTO_TRANSLATE_MODE_INHERIT** = ``0``
|
||
|
||
繼承父節點的 :ref:`auto_translate_mode<class_Node_property_auto_translate_mode>`\ 。這是新建立節點的預設值。
|
||
|
||
.. _class_Node_constant_AUTO_TRANSLATE_MODE_ALWAYS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>` **AUTO_TRANSLATE_MODE_ALWAYS** = ``1``
|
||
|
||
永遠自動翻譯。這是 :ref:`AUTO_TRANSLATE_MODE_DISABLED<class_Node_constant_AUTO_TRANSLATE_MODE_DISABLED>` 的相反,並且是根節點的預設值。
|
||
|
||
.. _class_Node_constant_AUTO_TRANSLATE_MODE_DISABLED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>` **AUTO_TRANSLATE_MODE_DISABLED** = ``2``
|
||
|
||
Never automatically translate. This is the inverse of :ref:`AUTO_TRANSLATE_MODE_ALWAYS<class_Node_constant_AUTO_TRANSLATE_MODE_ALWAYS>`.
|
||
|
||
String parsing for translation template generation will be skipped for this node and children that are set to :ref:`AUTO_TRANSLATE_MODE_INHERIT<class_Node_constant_AUTO_TRANSLATE_MODE_INHERIT>`.
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
常數
|
||
----
|
||
|
||
.. _class_Node_constant_NOTIFICATION_ENTER_TREE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_ENTER_TREE** = ``10`` :ref:`🔗<class_Node_constant_NOTIFICATION_ENTER_TREE>`
|
||
|
||
節點進入 :ref:`SceneTree<class_SceneTree>` 時收到通知。詳見 :ref:`_enter_tree()<class_Node_private_method__enter_tree>`\ 。
|
||
|
||
本通知於相關 :ref:`tree_entered<class_Node_signal_tree_entered>` 訊號\ *之前*\ 收到。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_EXIT_TREE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_EXIT_TREE** = ``11`` :ref:`🔗<class_Node_constant_NOTIFICATION_EXIT_TREE>`
|
||
|
||
Notification received when the node is about to exit a :ref:`SceneTree<class_SceneTree>`. See :ref:`_exit_tree()<class_Node_private_method__exit_tree>`.
|
||
|
||
This notification is received *after* the related :ref:`tree_exiting<class_Node_signal_tree_exiting>` signal.
|
||
|
||
This notification is sent in reversed order.
|
||
|
||
.. _class_Node_constant_NOTIFICATION_MOVED_IN_PARENT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_MOVED_IN_PARENT** = ``12`` :ref:`🔗<class_Node_constant_NOTIFICATION_MOVED_IN_PARENT>`
|
||
|
||
**已棄用:** This notification is no longer sent by the engine. Use :ref:`NOTIFICATION_CHILD_ORDER_CHANGED<class_Node_constant_NOTIFICATION_CHILD_ORDER_CHANGED>` instead.
|
||
|
||
|
||
|
||
.. _class_Node_constant_NOTIFICATION_READY:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_READY** = ``13`` :ref:`🔗<class_Node_constant_NOTIFICATION_READY>`
|
||
|
||
當節點就緒時收到通知。詳見 :ref:`_ready()<class_Node_private_method__ready>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_PAUSED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_PAUSED** = ``14`` :ref:`🔗<class_Node_constant_NOTIFICATION_PAUSED>`
|
||
|
||
節點暫停時收到通知。詳見 :ref:`process_mode<class_Node_property_process_mode>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_UNPAUSED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_UNPAUSED** = ``15`` :ref:`🔗<class_Node_constant_NOTIFICATION_UNPAUSED>`
|
||
|
||
節點恢復運作時收到通知。詳見 :ref:`process_mode<class_Node_property_process_mode>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_PHYSICS_PROCESS:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_PHYSICS_PROCESS** = ``16`` :ref:`🔗<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>`
|
||
|
||
當 :ref:`is_physics_processing()<class_Node_method_is_physics_processing>` 回傳 ``true`` 時,每個物理影格都會收到通知。詳見 :ref:`_physics_process()<class_Node_private_method__physics_process>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_PROCESS:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_PROCESS** = ``17`` :ref:`🔗<class_Node_constant_NOTIFICATION_PROCESS>`
|
||
|
||
當 :ref:`is_processing()<class_Node_method_is_processing>` 回傳 ``true`` 時,每個渲染影格都會收到通知。詳見 :ref:`_process()<class_Node_private_method__process>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_PARENTED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_PARENTED** = ``18`` :ref:`🔗<class_Node_constant_NOTIFICATION_PARENTED>`
|
||
|
||
當本節點被設為其他節點的子節點時收到通知(見 :ref:`add_child()<class_Node_method_add_child>` 及 :ref:`add_sibling()<class_Node_method_add_sibling>`\ )。
|
||
|
||
\ **注意:**\ 這\ *不代表*\ 本節點已進入 :ref:`SceneTree<class_SceneTree>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_UNPARENTED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_UNPARENTED** = ``19`` :ref:`🔗<class_Node_constant_NOTIFICATION_UNPARENTED>`
|
||
|
||
當父節點對本節點呼叫 :ref:`remove_child()<class_Node_method_remove_child>` 時收到通知。
|
||
|
||
\ **注意:**\ 這\ *不代表*\ 本節點已離開 :ref:`SceneTree<class_SceneTree>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_SCENE_INSTANTIATED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_SCENE_INSTANTIATED** = ``20`` :ref:`🔗<class_Node_constant_NOTIFICATION_SCENE_INSTANTIATED>`
|
||
|
||
僅有新實體化的場景根節點於 :ref:`PackedScene.instantiate()<class_PackedScene_method_instantiate>` 完成時\ *才*\ 會收到此通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_DRAG_BEGIN:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_DRAG_BEGIN** = ``21`` :ref:`🔗<class_Node_constant_NOTIFICATION_DRAG_BEGIN>`
|
||
|
||
拖曳操作開始時收到通知。所有節點都會收到,而非僅被拖曳者。
|
||
|
||
可透過拖曳有拖曳資料的 :ref:`Control<class_Control>`\ (見 :ref:`Control._get_drag_data()<class_Control_private_method__get_drag_data>`\ )或使用 :ref:`Control.force_drag()<class_Control_method_force_drag>` 觸發。
|
||
|
||
請用 :ref:`Viewport.gui_get_drag_data()<class_Viewport_method_gui_get_drag_data>` 取得拖曳資料。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_DRAG_END:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_DRAG_END** = ``22`` :ref:`🔗<class_Node_constant_NOTIFICATION_DRAG_END>`
|
||
|
||
拖曳操作結束時收到通知。
|
||
|
||
可用 :ref:`Viewport.gui_is_drag_successful()<class_Viewport_method_gui_is_drag_successful>` 檢查拖曳是否成功。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_PATH_RENAMED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_PATH_RENAMED** = ``23`` :ref:`🔗<class_Node_constant_NOTIFICATION_PATH_RENAMED>`
|
||
|
||
當本節點或其祖先節點的 :ref:`name<class_Node_property_name>` 被更改時收到通知。當節點從 :ref:`SceneTree<class_SceneTree>` 移除時\ *不會*\ 收到此通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_CHILD_ORDER_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_CHILD_ORDER_CHANGED** = ``24`` :ref:`🔗<class_Node_constant_NOTIFICATION_CHILD_ORDER_CHANGED>`
|
||
|
||
子節點列表異動時收到通知。新增、移動或移除子節點時皆會發出。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_INTERNAL_PROCESS:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_INTERNAL_PROCESS** = ``25`` :ref:`🔗<class_Node_constant_NOTIFICATION_INTERNAL_PROCESS>`
|
||
|
||
當 :ref:`is_processing_internal()<class_Node_method_is_processing_internal>` 回傳 ``true`` 時,每個渲染影格都會收到通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_INTERNAL_PHYSICS_PROCESS** = ``26`` :ref:`🔗<class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS>`
|
||
|
||
當 :ref:`is_physics_processing_internal()<class_Node_method_is_physics_processing_internal>` 回傳 ``true`` 時,每個物理影格都會收到通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_POST_ENTER_TREE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_POST_ENTER_TREE** = ``27`` :ref:`🔗<class_Node_constant_NOTIFICATION_POST_ENTER_TREE>`
|
||
|
||
當節點進入樹,即將收到 :ref:`NOTIFICATION_READY<class_Node_constant_NOTIFICATION_READY>` 前會收到此通知。不同於後者,每次進入樹時都會發送,而非只送一次。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_DISABLED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_DISABLED** = ``28`` :ref:`🔗<class_Node_constant_NOTIFICATION_DISABLED>`
|
||
|
||
節點被停用時收到通知。詳見 :ref:`PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_ENABLED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_ENABLED** = ``29`` :ref:`🔗<class_Node_constant_NOTIFICATION_ENABLED>`
|
||
|
||
節點停用後再度啟用時收到通知。詳見 :ref:`PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`\ 。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_RESET_PHYSICS_INTERPOLATION:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_RESET_PHYSICS_INTERPOLATION** = ``2001`` :ref:`🔗<class_Node_constant_NOTIFICATION_RESET_PHYSICS_INTERPOLATION>`
|
||
|
||
當本節點或其祖先節點呼叫 :ref:`reset_physics_interpolation()<class_Node_method_reset_physics_interpolation>` 時收到通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_EDITOR_PRE_SAVE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_EDITOR_PRE_SAVE** = ``9001`` :ref:`🔗<class_Node_constant_NOTIFICATION_EDITOR_PRE_SAVE>`
|
||
|
||
場景包含本節點且將被儲存於編輯器時,會於儲存前收到此通知。此通知僅於 Godot 編輯器中發送,匯出專案不會發生。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_EDITOR_POST_SAVE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_EDITOR_POST_SAVE** = ``9002`` :ref:`🔗<class_Node_constant_NOTIFICATION_EDITOR_POST_SAVE>`
|
||
|
||
場景包含本節點且儲存於編輯器後,會於儲存後立即收到通知。此通知僅於 Godot 編輯器中發送,匯出專案不會發生。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_MOUSE_ENTER:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_MOUSE_ENTER** = ``1002`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_MOUSE_ENTER>`
|
||
|
||
滑鼠進入視窗時收到的通知。
|
||
|
||
已在內嵌視窗、桌面與網頁平臺上實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_MOUSE_EXIT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_MOUSE_EXIT** = ``1003`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_MOUSE_EXIT>`
|
||
|
||
滑鼠離開視窗時收到的通知。
|
||
|
||
已在內嵌視窗、桌面與網頁平臺上實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_WINDOW_FOCUS_IN:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_WINDOW_FOCUS_IN** = ``1004`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_WINDOW_FOCUS_IN>`
|
||
|
||
當節點的上層 :ref:`Window<class_Window>` 獲得焦點時,會收到來自作業系統的通知。這可能是同一個引擎實例下兩個視窗間的焦點切換,或是從作業系統桌面或第三方應用程式切換到遊戲的視窗(此時也會收到 :ref:`NOTIFICATION_APPLICATION_FOCUS_IN<class_Node_constant_NOTIFICATION_APPLICATION_FOCUS_IN>`\ )。
|
||
|
||
\ :ref:`Window<class_Window>` 節點獲得焦點時會收到此通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_WINDOW_FOCUS_OUT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_WINDOW_FOCUS_OUT** = ``1005`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_WINDOW_FOCUS_OUT>`
|
||
|
||
當節點的上層 :ref:`Window<class_Window>` 失去焦點時,會收到來自作業系統的通知。這可能是同一個引擎實例下兩個視窗間的焦點切換,或是從遊戲視窗切換到作業系統桌面或第三方應用程式(此時也會收到 :ref:`NOTIFICATION_APPLICATION_FOCUS_OUT<class_Node_constant_NOTIFICATION_APPLICATION_FOCUS_OUT>`\ )。
|
||
|
||
\ :ref:`Window<class_Window>` 節點失去焦點時會收到此通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_CLOSE_REQUEST:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_CLOSE_REQUEST** = ``1006`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_CLOSE_REQUEST>`
|
||
|
||
收到來自作業系統的關閉請求通知(例如使用「關閉」按鈕或 :kbd:`Alt + F4` 關閉視窗)。
|
||
|
||
僅於桌面平臺實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_GO_BACK_REQUEST:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_GO_BACK_REQUEST** = ``1007`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_GO_BACK_REQUEST>`
|
||
|
||
收到來自作業系統的返回請求通知(例如在 Android 裝置上按下「返回」按鈕)。
|
||
|
||
僅於 Android 平臺實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_SIZE_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_SIZE_CHANGED** = ``1008`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_SIZE_CHANGED>`
|
||
|
||
當視窗尺寸改變時收到的通知。
|
||
|
||
\ **注意:** 僅有被調整大小的 :ref:`Window<class_Window>` 節點會收到此通知,不會傳遞給子節點。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_DPI_CHANGE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_DPI_CHANGE** = ``1009`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_DPI_CHANGE>`
|
||
|
||
當螢幕的 DPI 比例發生變更時,會收到來自作業系統的通知。僅於 macOS 平臺實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_VP_MOUSE_ENTER:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_VP_MOUSE_ENTER** = ``1010`` :ref:`🔗<class_Node_constant_NOTIFICATION_VP_MOUSE_ENTER>`
|
||
|
||
當滑鼠游標進入 :ref:`Viewport<class_Viewport>` 的可見區域且未被其他 :ref:`Control<class_Control>` 或 :ref:`Window<class_Window>` 遮擋時收到的通知,前提是其 :ref:`Viewport.gui_disable_input<class_Viewport_property_gui_disable_input>` 為 ``false``\ ,且無論目前是否有焦點。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_VP_MOUSE_EXIT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_VP_MOUSE_EXIT** = ``1011`` :ref:`🔗<class_Node_constant_NOTIFICATION_VP_MOUSE_EXIT>`
|
||
|
||
當滑鼠游標離開 :ref:`Viewport<class_Viewport>` 的可見區域且未被其他 :ref:`Control<class_Control>` 或 :ref:`Window<class_Window>` 遮擋時收到的通知,前提是其 :ref:`Viewport.gui_disable_input<class_Viewport_property_gui_disable_input>` 為 ``false``\ ,且無論目前是否有焦點。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_POSITION_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_POSITION_CHANGED** = ``1012`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_POSITION_CHANGED>`
|
||
|
||
當視窗被移動時收到的通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_OS_MEMORY_WARNING:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_OS_MEMORY_WARNING** = ``2009`` :ref:`🔗<class_Node_constant_NOTIFICATION_OS_MEMORY_WARNING>`
|
||
|
||
當應用程式超出分配的記憶體時,收到來自作業系統的通知。
|
||
|
||
僅於 iOS 平臺實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_TRANSLATION_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_TRANSLATION_CHANGED** = ``2010`` :ref:`🔗<class_Node_constant_NOTIFICATION_TRANSLATION_CHANGED>`
|
||
|
||
當翻譯可能變更時收到的通知。這可能由使用者變更語系、變更 :ref:`auto_translate_mode<class_Node_property_auto_translate_mode>`\ ,或節點進入場景樹時觸發。可用於即時響應語言變更,例如即時更新 UI 文字。搭配內建翻譯支援(如 :ref:`Object.tr()<class_Object_method_tr>`\ )時很有用。
|
||
|
||
\ **注意:** 此通知會與 :ref:`NOTIFICATION_ENTER_TREE<class_Node_constant_NOTIFICATION_ENTER_TREE>` 同時收到,所以如果你是在實體化場景時,子節點尚未初始化。你可以用這個通知設定此節點的翻譯、由腳本產生的子節點,或如果要存取在編輯器中加入的子節點,請確保節點已就緒(使用 :ref:`is_node_ready()<class_Node_method_is_node_ready>`\ )。
|
||
|
||
::
|
||
|
||
func _notification(what):
|
||
if what == NOTIFICATION_TRANSLATION_CHANGED:
|
||
if not is_node_ready():
|
||
await ready # 等待就緒訊號
|
||
$Label.text = atr("%d Bananas") % banana_counter
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_ABOUT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_ABOUT** = ``2011`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_ABOUT>`
|
||
|
||
當收到「關於」資訊請求時,收到來自作業系統的通知。
|
||
|
||
僅於 macOS 平臺實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_CRASH:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_CRASH** = ``2012`` :ref:`🔗<class_Node_constant_NOTIFICATION_CRASH>`
|
||
|
||
當引擎即將當機時,會收到來自 Godot 當機處理器的通知。
|
||
|
||
僅於桌面平臺且啟用當機處理器時實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_OS_IME_UPDATE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_OS_IME_UPDATE** = ``2013`` :ref:`🔗<class_Node_constant_NOTIFICATION_OS_IME_UPDATE>`
|
||
|
||
Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string).
|
||
|
||
Implemented on desktop and web platforms.
|
||
|
||
.. _class_Node_constant_NOTIFICATION_APPLICATION_RESUMED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_APPLICATION_RESUMED** = ``2014`` :ref:`🔗<class_Node_constant_NOTIFICATION_APPLICATION_RESUMED>`
|
||
|
||
當應用程式從暫停恢復時,從作業系統收到的通知。
|
||
|
||
僅適用於 Android 與 iOS 平台。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_APPLICATION_PAUSED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_APPLICATION_PAUSED** = ``2015`` :ref:`🔗<class_Node_constant_NOTIFICATION_APPLICATION_PAUSED>`
|
||
|
||
當應用程式被暫停時,從作業系統收到的通知。
|
||
|
||
僅適用於 Android 與 iOS 平台。
|
||
|
||
\ **注意:**\ 在 iOS 上,這個訊號觸發後,你大約只有 5 秒可以完成相關任務。超過這個限制,iOS 將會直接終止應用程式,而非單純暫停。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_APPLICATION_FOCUS_IN:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_APPLICATION_FOCUS_IN** = ``2016`` :ref:`🔗<class_Node_constant_NOTIFICATION_APPLICATION_FOCUS_IN>`
|
||
|
||
當應用程式獲得焦點時,從作業系統收到的通知,即當焦點從作業系統桌面或第三方應用程式切換到 Godot 任一開啟視窗時。
|
||
|
||
在桌面與行動平台皆有實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_APPLICATION_FOCUS_OUT** = ``2017`` :ref:`🔗<class_Node_constant_NOTIFICATION_APPLICATION_FOCUS_OUT>`
|
||
|
||
當應用程式失去焦點時,從作業系統收到的通知,即當焦點從 Godot 任一開啟視窗切換到作業系統桌面或第三方應用程式時。
|
||
|
||
在桌面與行動平台皆有實作。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_TEXT_SERVER_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_TEXT_SERVER_CHANGED** = ``2018`` :ref:`🔗<class_Node_constant_NOTIFICATION_TEXT_SERVER_CHANGED>`
|
||
|
||
當 :ref:`TextServer<class_TextServer>` 變更時收到的通知。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_ACCESSIBILITY_UPDATE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_ACCESSIBILITY_UPDATE** = ``3000`` :ref:`🔗<class_Node_constant_NOTIFICATION_ACCESSIBILITY_UPDATE>`
|
||
|
||
Notification received when an accessibility information update is required.
|
||
|
||
.. _class_Node_constant_NOTIFICATION_ACCESSIBILITY_INVALIDATE:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_ACCESSIBILITY_INVALIDATE** = ``3001`` :ref:`🔗<class_Node_constant_NOTIFICATION_ACCESSIBILITY_INVALIDATE>`
|
||
|
||
Notification received when accessibility elements are invalidated. All node accessibility elements are automatically deleted after receiving this message, therefore all existing references to such elements should be discarded.
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
屬性說明
|
||
--------
|
||
|
||
.. _class_Node_property_auto_translate_mode:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>` **auto_translate_mode** = ``0`` :ref:`🔗<class_Node_property_auto_translate_mode>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_auto_translate_mode**\ (\ value\: :ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>`\ )
|
||
- :ref:`AutoTranslateMode<enum_Node_AutoTranslateMode>` **get_auto_translate_mode**\ (\ )
|
||
|
||
Defines if any text should automatically change to its translated version depending on the current locale (for nodes such as :ref:`Label<class_Label>`, :ref:`RichTextLabel<class_RichTextLabel>`, :ref:`Window<class_Window>`, etc.). Also decides if the node's strings should be parsed for translation template generation.
|
||
|
||
\ **Note:** For the root node, auto translate mode can also be set via :ref:`ProjectSettings.internationalization/rendering/root_node_auto_translate<class_ProjectSettings_property_internationalization/rendering/root_node_auto_translate>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_editor_description:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`String<class_String>` **editor_description** = ``""`` :ref:`🔗<class_Node_property_editor_description>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_editor_description**\ (\ value\: :ref:`String<class_String>`\ )
|
||
- :ref:`String<class_String>` **get_editor_description**\ (\ )
|
||
|
||
本節點的自訂描述。滑鼠懸停於編輯器的「場景」面板上該節點時,將顯示此描述作為工具提示。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_multiplayer:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`MultiplayerAPI<class_MultiplayerAPI>` **multiplayer** :ref:`🔗<class_Node_property_multiplayer>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`MultiplayerAPI<class_MultiplayerAPI>` **get_multiplayer**\ (\ )
|
||
|
||
與本節點關聯的 :ref:`MultiplayerAPI<class_MultiplayerAPI>` 執行個體。請參見 :ref:`SceneTree.get_multiplayer()<class_SceneTree_method_get_multiplayer>`\ 。
|
||
|
||
\ **注意:**\ 重新命名或移動節點時,\ :ref:`MultiplayerAPI<class_MultiplayerAPI>` 不會自動移至新路徑,需手動更新。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_name:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`StringName<class_StringName>` **name** :ref:`🔗<class_Node_property_name>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_name**\ (\ value\: :ref:`StringName<class_StringName>`\ )
|
||
- :ref:`StringName<class_StringName>` **get_name**\ (\ )
|
||
|
||
節點的名稱。該名稱在同一父節點下必須唯一。若設定為已存在的兄弟節點名稱,該節點會自動重新命名。
|
||
|
||
\ **注意:**\ 更改名稱時,下列字元會被取代為底線:(``.`` ``:`` ``@`` ``/`` ``"`` ``%``)。特別是 ``@`` 保留給自動產生名稱。詳見 :ref:`String.validate_node_name()<class_String_method_validate_node_name>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_owner:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Node<class_Node>` **owner** :ref:`🔗<class_Node_property_owner>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_owner**\ (\ value\: :ref:`Node<class_Node>`\ )
|
||
- :ref:`Node<class_Node>` **get_owner**\ (\ )
|
||
|
||
本節點的擁有者。擁有者必須是本節點的祖先。當將擁有者節點打包為 :ref:`PackedScene<class_PackedScene>` 時,其所擁有的所有節點也會一併儲存。詳見 :ref:`unique_name_in_owner<class_Node_property_unique_name_in_owner>`\ 。
|
||
|
||
\ **注意:**\ 在編輯器中,不屬於場景根節點的節點通常不會顯示於「場景」面板,且\ **不會**\ 被儲存。為避免此情況,請在呼叫 :ref:`add_child()<class_Node_method_add_child>` 後設定 owner。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_physics_interpolation_mode:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` **physics_interpolation_mode** = ``0`` :ref:`🔗<class_Node_property_physics_interpolation_mode>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_physics_interpolation_mode**\ (\ value\: :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>`\ )
|
||
- :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` **get_physics_interpolation_mode**\ (\ )
|
||
|
||
The physics interpolation mode to use for this node. Only effective if :ref:`ProjectSettings.physics/common/physics_interpolation<class_ProjectSettings_property_physics/common/physics_interpolation>` or :ref:`SceneTree.physics_interpolation<class_SceneTree_property_physics_interpolation>` is ``true``.
|
||
|
||
By default, nodes inherit the physics interpolation mode from their parent. This property can enable or disable physics interpolation individually for each node, regardless of their parents' physics interpolation mode.
|
||
|
||
\ **Note:** Some node types like :ref:`VehicleWheel3D<class_VehicleWheel3D>` have physics interpolation disabled by default, as they rely on their own custom solution.
|
||
|
||
\ **Note:** When teleporting a node to a distant position, it's recommended to temporarily disable interpolation with :ref:`reset_physics_interpolation()<class_Node_method_reset_physics_interpolation>` *after* moving the node. This avoids creating a visual streak between the old and new positions.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_process_mode:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`ProcessMode<enum_Node_ProcessMode>` **process_mode** = ``0`` :ref:`🔗<class_Node_property_process_mode>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_process_mode**\ (\ value\: :ref:`ProcessMode<enum_Node_ProcessMode>`\ )
|
||
- :ref:`ProcessMode<enum_Node_ProcessMode>` **get_process_mode**\ (\ )
|
||
|
||
The node's processing behavior. To check if the node can process in its current mode, use :ref:`can_process()<class_Node_method_can_process>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_process_physics_priority:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **process_physics_priority** = ``0`` :ref:`🔗<class_Node_property_process_physics_priority>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_physics_process_priority**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_physics_process_priority**\ (\ )
|
||
|
||
與 :ref:`process_priority<class_Node_property_process_priority>` 類似,但用於 :ref:`NOTIFICATION_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>`\ 、\ :ref:`_physics_process()<class_Node_private_method__physics_process>` 或 :ref:`NOTIFICATION_INTERNAL_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_process_priority:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **process_priority** = ``0`` :ref:`🔗<class_Node_property_process_priority>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_process_priority**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_process_priority**\ (\ )
|
||
|
||
節點執行處理回呼函式(\ :ref:`_process()<class_Node_private_method__process>`\ 、\ :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ 、\ :ref:`NOTIFICATION_INTERNAL_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PROCESS>`\ )的順序。優先值\ *較低*\ 的節點會優先呼叫回呼,與樹序無關。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_process_thread_group:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>` **process_thread_group** = ``0`` :ref:`🔗<class_Node_property_process_thread_group>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_process_thread_group**\ (\ value\: :ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>`\ )
|
||
- :ref:`ProcessThreadGroup<enum_Node_ProcessThreadGroup>` **get_process_thread_group**\ (\ )
|
||
|
||
設定本節點的處理執行緒群組(即決定是否在主執行緒或子執行緒收 :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ 、\ :ref:`NOTIFICATION_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>`\ 、\ :ref:`_process()<class_Node_private_method__process>`\ 、\ :ref:`_physics_process()<class_Node_private_method__physics_process>` 及其內部版本)。
|
||
|
||
預設為 :ref:`PROCESS_THREAD_GROUP_INHERIT<class_Node_constant_PROCESS_THREAD_GROUP_INHERIT>`\ ,表示本節點與父節點同屬一執行緒群組。群組內節點會同步處理,與其他群組分開(由 :ref:`process_thread_group_order<class_Node_property_process_thread_group_order>` 決定)。若設為 :ref:`PROCESS_THREAD_GROUP_SUB_THREAD<class_Node_constant_PROCESS_THREAD_GROUP_SUB_THREAD>`\ ,群組會在子執行緒(非主執行緒)執行;設為 :ref:`PROCESS_THREAD_GROUP_MAIN_THREAD<class_Node_constant_PROCESS_THREAD_GROUP_MAIN_THREAD>` 則於主執行緒執行。若父祖節點皆為繼承,則屬於\ *預設執行緒群組*\ ,於主執行緒處理,順序為 0。
|
||
|
||
在子執行緒處理時,不可存取群組外大多數節點函式(除錯模式會報錯)。請用 :ref:`Object.call_deferred()<class_Object_method_call_deferred>`\ 、\ :ref:`call_thread_safe()<class_Node_method_call_thread_safe>`\ 、\ :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>` 等方式與主執行緒(或其他群組)溝通。
|
||
|
||
理解執行緒群組時,任何非 :ref:`PROCESS_THREAD_GROUP_INHERIT<class_Node_constant_PROCESS_THREAD_GROUP_INHERIT>` 的節點都會將設為繼承的子孫節點納入其群組,群組內所有節點會同步與其包含它們的節點一同處理。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_process_thread_group_order:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **process_thread_group_order** :ref:`🔗<class_Node_property_process_thread_group_order>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_process_thread_group_order**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_process_thread_group_order**\ (\ )
|
||
|
||
變更處理執行緒群組的順序。數值較小的群組會比數值大的群組先處理。例如:可讓大量節點先於子執行緒處理,之後再由主執行緒的群組收集結果。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_process_thread_messages:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
|bitfield|\[:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>`\] **process_thread_messages** :ref:`🔗<class_Node_property_process_thread_messages>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_process_thread_messages**\ (\ value\: |bitfield|\[:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>`\]\ )
|
||
- |bitfield|\[:ref:`ProcessThreadMessages<enum_Node_ProcessThreadMessages>`\] **get_process_thread_messages**\ (\ )
|
||
|
||
設定目前執行緒群組是否會處理訊息(於執行緒中呼叫 :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>`\ ),以及是否要於一般處理或物理處理回呼時接收訊息。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_scene_file_path:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`String<class_String>` **scene_file_path** :ref:`🔗<class_Node_property_scene_file_path>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_scene_file_path**\ (\ value\: :ref:`String<class_String>`\ )
|
||
- :ref:`String<class_String>` **get_scene_file_path**\ (\ )
|
||
|
||
若本節點由 :ref:`PackedScene<class_PackedScene>` 檔案實體化,則為原場景的檔案路徑。僅場景根節點包含此資訊。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_property_unique_name_in_owner:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **unique_name_in_owner** = ``false`` :ref:`🔗<class_Node_property_unique_name_in_owner>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_unique_name_in_owner**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_unique_name_in_owner**\ (\ )
|
||
|
||
若為 ``true``\ ,則可從擁有相同 :ref:`owner<class_Node_property_owner>` 的任何節點或 :ref:`owner<class_Node_property_owner>` 本身,利用 :ref:`get_node()<class_Node_method_get_node>` 的特殊 ``%Name`` 語法存取本節點。
|
||
|
||
\ **注意:**\ 若另一個相同 :ref:`owner<class_Node_property_owner>` 的節點名稱與本節點相同,該節點將不再能以唯一方式存取。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
方法說明
|
||
--------
|
||
|
||
.. _class_Node_private_method__enter_tree:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_enter_tree**\ (\ ) |virtual| :ref:`🔗<class_Node_private_method__enter_tree>`
|
||
|
||
當節點進入 :ref:`SceneTree<class_SceneTree>` 時被呼叫(例如產生實體、場景切換,或腳本中呼叫 :ref:`add_child()<class_Node_method_add_child>` 之後)。若節點有子節點,會先呼叫自身的 :ref:`_enter_tree()<class_Node_private_method__enter_tree>` 回呼,再呼叫子節點的回呼。
|
||
|
||
對應於 :ref:`Object._notification()<class_Object_private_method__notification>` 中的 :ref:`NOTIFICATION_ENTER_TREE<class_Node_constant_NOTIFICATION_ENTER_TREE>` 通知。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__exit_tree:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_exit_tree**\ (\ ) |virtual| :ref:`🔗<class_Node_private_method__exit_tree>`
|
||
|
||
當節點即將離開 :ref:`SceneTree<class_SceneTree>` 時被呼叫(例如釋放、場景切換,或腳本中呼叫 :ref:`remove_child()<class_Node_method_remove_child>` 之後)。如果節點有子節點,會在所有子節點離開後最後呼叫自身的 :ref:`_exit_tree()<class_Node_private_method__exit_tree>` 回呼。
|
||
|
||
對應於 :ref:`Object._notification()<class_Object_private_method__notification>` 中的 :ref:`NOTIFICATION_EXIT_TREE<class_Node_constant_NOTIFICATION_EXIT_TREE>` 通知,以及 :ref:`tree_exiting<class_Node_signal_tree_exiting>` 訊號。若要在節點已經離開活動樹時接收通知,請連接 :ref:`tree_exited<class_Node_signal_tree_exited>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__get_accessibility_configuration_warnings:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PackedStringArray<class_PackedStringArray>` **_get_accessibility_configuration_warnings**\ (\ ) |virtual| |const| :ref:`🔗<class_Node_private_method__get_accessibility_configuration_warnings>`
|
||
|
||
The elements in the array returned from this method are displayed as warnings in the Scene dock if the script that overrides it is a ``tool`` script, and accessibility warnings are enabled in the editor settings.
|
||
|
||
Returning an empty array produces no warnings.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__get_configuration_warnings:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PackedStringArray<class_PackedStringArray>` **_get_configuration_warnings**\ (\ ) |virtual| |const| :ref:`🔗<class_Node_private_method__get_configuration_warnings>`
|
||
|
||
若覆寫此方法的腳本為 ``tool`` 腳本,這個方法回傳陣列中的元素會在「場景」面板顯示為警告。
|
||
|
||
回傳空陣列則不會顯示警告。
|
||
|
||
當需要更新這個節點的警告時,請呼叫 :ref:`update_configuration_warnings()<class_Node_method_update_configuration_warnings>`\ 。
|
||
|
||
::
|
||
|
||
@export var energy = 0:
|
||
set(value):
|
||
energy = value
|
||
update_configuration_warnings()
|
||
|
||
func _get_configuration_warnings():
|
||
if energy < 0:
|
||
return ["Energy 必須大於等於 0。"]
|
||
else:
|
||
return []
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__get_focused_accessibility_element:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`RID<class_RID>` **_get_focused_accessibility_element**\ (\ ) |virtual| |const| :ref:`🔗<class_Node_private_method__get_focused_accessibility_element>`
|
||
|
||
Called during accessibility information updates to determine the currently focused sub-element, should return a sub-element RID or the value returned by :ref:`get_accessibility_element()<class_Node_method_get_accessibility_element>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| :ref:`🔗<class_Node_private_method__input>`
|
||
|
||
有輸入事件時會被呼叫。輸入事件會沿著節點樹向上傳遞,直到被某節點消耗為止。
|
||
|
||
只有啟用輸入處理時才會呼叫,如覆寫本方法會自動啟用,也可用 :ref:`set_process_input()<class_Node_method_set_process_input>` 切換。
|
||
|
||
若要消耗輸入事件並阻止其繼續傳遞,可呼叫 :ref:`Viewport.set_input_as_handled()<class_Viewport_method_set_input_as_handled>`\ 。
|
||
|
||
遊戲中建議使用 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>` 或 :ref:`_unhandled_key_input()<class_Node_private_method__unhandled_key_input>`\ ,這樣 GUI 可以優先攔截事件。
|
||
|
||
\ **注意:**\ 僅當節點存在於場景樹中(即不是孤立節點)時才會呼叫本方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__physics_process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_physics_process**\ (\ delta\: :ref:`float<class_float>`\ ) |virtual| :ref:`🔗<class_Node_private_method__physics_process>`
|
||
|
||
Called once on each physics tick, and allows Nodes to synchronize their logic with physics ticks. ``delta`` is the logical time between physics ticks in seconds and is equal to :ref:`Engine.time_scale<class_Engine_property_time_scale>` / :ref:`Engine.physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`.
|
||
|
||
It is only called if physics processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with :ref:`set_physics_process()<class_Node_method_set_physics_process>`.
|
||
|
||
Processing happens in order of :ref:`process_physics_priority<class_Node_property_process_physics_priority>`, lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal).
|
||
|
||
Corresponds to the :ref:`NOTIFICATION_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>` notification in :ref:`Object._notification()<class_Object_private_method__notification>`.
|
||
|
||
\ **Note:** This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
|
||
|
||
\ **Note:** Accumulated ``delta`` may diverge from real world seconds.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_process**\ (\ delta\: :ref:`float<class_float>`\ ) |virtual| :ref:`🔗<class_Node_private_method__process>`
|
||
|
||
Called on each idle frame, prior to rendering, and after physics ticks have been processed. ``delta`` is the time between frames in seconds.
|
||
|
||
It is only called if processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with :ref:`set_process()<class_Node_method_set_process>`.
|
||
|
||
Processing happens in order of :ref:`process_priority<class_Node_property_process_priority>`, lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal).
|
||
|
||
Corresponds to the :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>` notification in :ref:`Object._notification()<class_Object_private_method__notification>`.
|
||
|
||
\ **Note:** This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
|
||
|
||
\ **Note:** When the engine is struggling and the frame rate is lowered, ``delta`` will increase. When ``delta`` is increased, it's capped at a maximum of :ref:`Engine.time_scale<class_Engine_property_time_scale>` \* :ref:`Engine.max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` / :ref:`Engine.physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`. As a result, accumulated ``delta`` may not represent real world time.
|
||
|
||
\ **Note:** When ``--fixed-fps`` is enabled or the engine is running in Movie Maker mode (see :ref:`MovieWriter<class_MovieWriter>`), process ``delta`` will always be the same for every frame, regardless of how much time the frame took to render.
|
||
|
||
\ **Note:** Frame delta may be post-processed by :ref:`OS.delta_smoothing<class_OS_property_delta_smoothing>` if this is enabled for the project.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__ready:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_ready**\ (\ ) |virtual| :ref:`🔗<class_Node_private_method__ready>`
|
||
|
||
當節點「就緒」時(即自己與所有子節點都已進入場景樹)會被呼叫。若節點有子節點,會先觸發子節點的 :ref:`_ready()<class_Node_private_method__ready>` 回呼,然後才是父節點。
|
||
|
||
對應於 :ref:`Object._notification()<class_Object_private_method__notification>` 內的 :ref:`NOTIFICATION_READY<class_Node_constant_NOTIFICATION_READY>` 通知。另可參考變數用的 ``@onready`` 標註。
|
||
|
||
本方法通常用於初始化。若需更早期初始化,可用 :ref:`Object._init()<class_Object_private_method__init>`\ 。另見 :ref:`_enter_tree()<class_Node_private_method__enter_tree>`\ 。
|
||
|
||
\ **注意:**\ 每個節點只會被呼叫一次 :ref:`_ready()<class_Node_private_method__ready>`\ 。從場景樹移除再重新加入,\ **不會**\ 再自動呼叫,可用 :ref:`request_ready()<class_Node_method_request_ready>` 於再次加入前手動請求呼叫。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__shortcut_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_shortcut_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| :ref:`🔗<class_Node_private_method__shortcut_input>`
|
||
|
||
當 :ref:`InputEventKey<class_InputEventKey>`\ 、\ :ref:`InputEventShortcut<class_InputEventShortcut>` 或 :ref:`InputEventJoypadButton<class_InputEventJoypadButton>` 尚未被 :ref:`_input()<class_Node_private_method__input>` 或任何 GUI :ref:`Control<class_Control>` 專案消耗時會呼叫。這個方法會在 :ref:`_unhandled_key_input()<class_Node_private_method__unhandled_key_input>` 與 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>` 之前呼叫。輸入事件會沿樹狀結構向上傳播,直到被節點消耗為止。
|
||
|
||
只有啟用快捷鍵處理時才會呼叫,覆寫本方法會自動啟用,也可用 :ref:`set_process_shortcut_input()<class_Node_method_set_process_shortcut_input>` 切換。
|
||
|
||
若要消耗輸入事件並阻止其繼續傳遞,可呼叫 :ref:`Viewport.set_input_as_handled()<class_Viewport_method_set_input_as_handled>`\ 。
|
||
|
||
本方法可用於處理快捷鍵。若為一般 GUI 事件,請用 :ref:`_input()<class_Node_private_method__input>`\ ;遊戲事件通常適合用 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>` 或 :ref:`_unhandled_key_input()<class_Node_private_method__unhandled_key_input>` 處理。
|
||
|
||
\ **注意:**\ 僅當節點存在於場景樹中(即不是孤立節點)時才會呼叫本方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__unhandled_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_unhandled_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| :ref:`🔗<class_Node_private_method__unhandled_input>`
|
||
|
||
當 :ref:`InputEvent<class_InputEvent>` 尚未被 :ref:`_input()<class_Node_private_method__input>` 或任何 GUI :ref:`Control<class_Control>` 專案消耗時會呼叫。這會在 :ref:`_shortcut_input()<class_Node_private_method__shortcut_input>` 和 :ref:`_unhandled_key_input()<class_Node_private_method__unhandled_key_input>` 之後呼叫。輸入事件會沿樹狀結構向上傳播,直到被節點消耗為止。
|
||
|
||
只有啟用未處理輸入處理時才會呼叫,覆寫本方法會自動啟用,也可用 :ref:`set_process_unhandled_input()<class_Node_method_set_process_unhandled_input>` 切換。
|
||
|
||
若要消耗輸入事件並阻止其繼續傳遞,可呼叫 :ref:`Viewport.set_input_as_handled()<class_Viewport_method_set_input_as_handled>`\ 。
|
||
|
||
對於遊戲輸入,本方法通常比 :ref:`_input()<class_Node_private_method__input>` 更合適,因為 GUI 事件優先度較高。若是鍵盤快捷鍵,請改用 :ref:`_shortcut_input()<class_Node_private_method__shortcut_input>`\ ,因為它會先被呼叫。若需處理鍵盤事件,建議基於效能考量使用 :ref:`_unhandled_key_input()<class_Node_private_method__unhandled_key_input>`\ 。
|
||
|
||
\ **注意:**\ 僅當節點存在於場景樹中(即不是孤立節點)時才會呼叫本方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_private_method__unhandled_key_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_unhandled_key_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| :ref:`🔗<class_Node_private_method__unhandled_key_input>`
|
||
|
||
當 :ref:`InputEventKey<class_InputEventKey>` 沒有被 :ref:`_input()<class_Node_private_method__input>` 或任何 GUI :ref:`Control<class_Control>` 元件消耗時呼叫。這方法會在 :ref:`_shortcut_input()<class_Node_private_method__shortcut_input>` 之後,\ :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>` 之前呼叫。輸入事件會沿著節點樹向上傳播直到被消耗。
|
||
|
||
僅當啟用未處理按鍵輸入處理時才會呼叫,覆寫本方法會自動啟用,也可用 :ref:`set_process_unhandled_key_input()<class_Node_method_set_process_unhandled_key_input>` 切換。
|
||
|
||
要消耗輸入事件並阻止其繼續傳遞,可呼叫 :ref:`Viewport.set_input_as_handled()<class_Viewport_method_set_input_as_handled>`\ 。
|
||
|
||
此方法可用於處理帶有 :kbd:`Alt`\ 、\ :kbd:`Alt + Ctrl`\ 、\ :kbd:`Alt + Shift` 修飾鍵的 Unicode 字元輸入(在快捷鍵處理完畢後)。
|
||
|
||
對於遊戲輸入,這個方法和 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>` 通常比 :ref:`_input()<class_Node_private_method__input>` 更適合,因為應先處理 GUI 事件。本方法效能也優於 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>`\ ,因為像 :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` 這類無關事件會自動被過濾。若需處理快捷鍵,請改用 :ref:`_shortcut_input()<class_Node_private_method__shortcut_input>`\ 。
|
||
|
||
\ **注意:**\ 僅當節點存在於場景樹中(即不是孤立節點)時才會呼叫本方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_add_child:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_child**\ (\ node\: :ref:`Node<class_Node>`, force_readable_name\: :ref:`bool<class_bool>` = false, internal\: :ref:`InternalMode<enum_Node_InternalMode>` = 0\ ) :ref:`🔗<class_Node_method_add_child>`
|
||
|
||
Adds a child ``node``. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
|
||
|
||
If ``force_readable_name`` is ``true``, improves the readability of the added ``node``. If not named, the ``node`` is renamed to its type, and if it shares :ref:`name<class_Node_property_name>` with a sibling, a number is suffixed more appropriately. This operation is very slow. As such, it is recommended leaving this to ``false``, which assigns a dummy name featuring ``@`` in both situations.
|
||
|
||
If ``internal`` is different than :ref:`INTERNAL_MODE_DISABLED<class_Node_constant_INTERNAL_MODE_DISABLED>`, the child will be added as internal node. These nodes are ignored by methods like :ref:`get_children()<class_Node_method_get_children>`, unless their parameter ``include_internal`` is ``true``. It also prevents these nodes being duplicated with their parent. The intended usage is to hide the internal nodes from the user, so the user won't accidentally delete or modify them. Used by some GUI nodes, e.g. :ref:`ColorPicker<class_ColorPicker>`.
|
||
|
||
\ **Note:** If ``node`` already has a parent, this method will fail. Use :ref:`remove_child()<class_Node_method_remove_child>` first to remove ``node`` from its current parent. For example:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
var child_node = get_child(0)
|
||
if child_node.get_parent():
|
||
child_node.get_parent().remove_child(child_node)
|
||
add_child(child_node)
|
||
|
||
.. code-tab:: csharp
|
||
|
||
Node childNode = GetChild(0);
|
||
if (childNode.GetParent() != null)
|
||
{
|
||
childNode.GetParent().RemoveChild(childNode);
|
||
}
|
||
AddChild(childNode);
|
||
|
||
|
||
|
||
If you need the child node to be added below a specific node in the list of children, use :ref:`add_sibling()<class_Node_method_add_sibling>` instead of this method.
|
||
|
||
\ **Note:** If you want a child to be persisted to a :ref:`PackedScene<class_PackedScene>`, you must set :ref:`owner<class_Node_property_owner>` in addition to calling :ref:`add_child()<class_Node_method_add_child>`. This is typically relevant for :doc:`tool scripts <../tutorials/plugins/running_code_in_the_editor>` and :doc:`editor plugins <../tutorials/plugins/editor/index>`. If :ref:`add_child()<class_Node_method_add_child>` is called without setting :ref:`owner<class_Node_property_owner>`, the newly added **Node** will not be visible in the scene tree, though it will be visible in the 2D/3D view.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_add_sibling:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_sibling**\ (\ sibling\: :ref:`Node<class_Node>`, force_readable_name\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Node_method_add_sibling>`
|
||
|
||
將 ``sibling`` 節點新增到本節點的父節點,並將其放在本節點的下方。
|
||
|
||
若 ``force_readable_name`` 為 ``true``\ ,會提升新增 ``sibling`` 的名稱可讀性。若未命名,則 ``sibling`` 會以其型別命名;若與其他同級節點有相同 :ref:`name<class_Node_property_name>`\ ,則會自動加上合適的數字後綴。此操作非常緩慢,建議將此值保留為 ``false``\ ,此時會自動分配包含 ``@`` 的臨時名稱。
|
||
|
||
若不需將子節點插入於特定節點下方,請使用 :ref:`add_child()<class_Node_method_add_child>` 取代本方法。
|
||
|
||
\ **注意:**\ 若本節點為內部節點,則所新增的同級節點也會是內部節點(詳見 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 參數)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_add_to_group:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_to_group**\ (\ group\: :ref:`StringName<class_StringName>`, persistent\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Node_method_add_to_group>`
|
||
|
||
Adds the node to the ``group``. Groups can be helpful to organize a subset of nodes, for example ``"enemies"`` or ``"collectables"``. See notes in the description, and the group methods in :ref:`SceneTree<class_SceneTree>`.
|
||
|
||
If ``persistent`` is ``true``, the group will be stored when saved inside a :ref:`PackedScene<class_PackedScene>`. All groups created and displayed in the Groups dock are persistent.
|
||
|
||
\ **Note:** To improve performance, the order of group names is *not* guaranteed and may vary between project runs. Therefore, do not rely on the group order.
|
||
|
||
\ **Note:** :ref:`SceneTree<class_SceneTree>`'s group methods will *not* work on this node if not inside the tree (see :ref:`is_inside_tree()<class_Node_method_is_inside_tree>`).
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_atr:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **atr**\ (\ message\: :ref:`String<class_String>`, context\: :ref:`StringName<class_StringName>` = ""\ ) |const| :ref:`🔗<class_Node_method_atr>`
|
||
|
||
利用專案設定中配置的翻譯目錄翻譯 ``message``\ ,可以進一步指定 ``context`` 來協助翻譯。大多數 :ref:`Control<class_Control>` 節點會自動翻譯字串,因此本方法主要用於格式化字串或自訂繪製文字。
|
||
|
||
本方法運作方式與 :ref:`Object.tr()<class_Object_method_tr>` 相同,但會考慮 :ref:`auto_translate_mode<class_Node_property_auto_translate_mode>` 狀態。
|
||
|
||
若 :ref:`Object.can_translate_messages()<class_Object_method_can_translate_messages>` 為 ``false`` 或無翻譯可用,則會直接返回原始 ``message``\ 。請參見 :ref:`Object.set_message_translation()<class_Object_method_set_message_translation>`\ 。
|
||
|
||
詳細範例請參閱 :doc:`國際化遊戲 <../tutorials/i18n/internationalizing_games>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_atr_n:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **atr_n**\ (\ message\: :ref:`String<class_String>`, plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = ""\ ) |const| :ref:`🔗<class_Node_method_atr_n>`
|
||
|
||
利用專案設定中配置的翻譯目錄翻譯 ``message`` 或 ``plural_message``\ ,可進一步指定 ``context`` 協助翻譯。
|
||
|
||
本方法與 :ref:`Object.tr_n()<class_Object_method_tr_n>` 相同,但會參考 :ref:`auto_translate_mode<class_Node_property_auto_translate_mode>` 狀態。
|
||
|
||
若 :ref:`Object.can_translate_messages()<class_Object_method_can_translate_messages>` 為 ``false`` 或無翻譯可用,則直接返回 ``message`` 或 ``plural_message``\ 。請參見 :ref:`Object.set_message_translation()<class_Object_method_set_message_translation>`\ 。
|
||
|
||
\ ``n`` 代表主題的數量/數值,翻譯系統會據此取得適用語言的正確複數形式。
|
||
|
||
詳細範例請參閱 :doc:`使用 gettext 進行在地化 <../tutorials/i18n/localization_using_gettext>`\ 。
|
||
|
||
\ **注意:**\ 負數及 :ref:`float<class_float>` 型別可能不適用於某些可數主題。建議以 :ref:`atr()<class_Node_method_atr>` 處理這些情況。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_call_deferred_thread_group:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Variant<class_Variant>` **call_deferred_thread_group**\ (\ method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| :ref:`🔗<class_Node_method_call_deferred_thread_group>`
|
||
|
||
本函式類似 :ref:`Object.call_deferred()<class_Object_method_call_deferred>`\ ,但會在節點執行緒組被處理時執行。若節點執行緒組於子執行緒中處理,則會在該執行緒於呼叫 :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ 、\ :ref:`NOTIFICATION_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>`\ 、\ :ref:`_process()<class_Node_private_method__process>` 或 :ref:`_physics_process()<class_Node_private_method__physics_process>` 或其內部版本之前執行此呼叫。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_call_thread_safe:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Variant<class_Variant>` **call_thread_safe**\ (\ method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| :ref:`🔗<class_Node_method_call_thread_safe>`
|
||
|
||
本函式能保證無論是否於執行緒中執行皆能成功呼叫。若於不允許呼叫的執行緒中執行,則該呼叫會自動延後。否則會直接呼叫。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_can_auto_translate:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **can_auto_translate**\ (\ ) |const| :ref:`🔗<class_Node_method_can_auto_translate>`
|
||
|
||
Returns ``true`` if this node can automatically translate messages depending on the current locale. See :ref:`auto_translate_mode<class_Node_property_auto_translate_mode>`, :ref:`atr()<class_Node_method_atr>`, and :ref:`atr_n()<class_Node_method_atr_n>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_can_process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **can_process**\ (\ ) |const| :ref:`🔗<class_Node_method_can_process>`
|
||
|
||
若節點可接收處理通知及輸入回呼(如 :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ 、\ :ref:`_input()<class_Node_private_method__input>` 等)來自 :ref:`SceneTree<class_SceneTree>` 或 :ref:`Viewport<class_Viewport>`\ ,則回傳 ``true``\ 。回傳值取決於 :ref:`process_mode<class_Node_property_process_mode>`\ :
|
||
|
||
- 設為 :ref:`PROCESS_MODE_PAUSABLE<class_Node_constant_PROCESS_MODE_PAUSABLE>` 時,僅當遊戲執行中(\ :ref:`SceneTree.paused<class_SceneTree_property_paused>` 為 ``false``\ )時回傳 ``true``\ ;
|
||
|
||
- 設為 :ref:`PROCESS_MODE_WHEN_PAUSED<class_Node_constant_PROCESS_MODE_WHEN_PAUSED>` 時,僅當遊戲暫停(\ :ref:`SceneTree.paused<class_SceneTree_property_paused>` 為 ``true``\ )時回傳 ``true``\ ;
|
||
|
||
- 設為 :ref:`PROCESS_MODE_ALWAYS<class_Node_constant_PROCESS_MODE_ALWAYS>` 時,總是回傳 ``true``\ ;
|
||
|
||
- 設為 :ref:`PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>` 時,總是回傳 ``false``\ ;
|
||
|
||
- 設為 :ref:`PROCESS_MODE_INHERIT<class_Node_constant_PROCESS_MODE_INHERIT>` 時,則繼承父節點的 :ref:`process_mode<class_Node_property_process_mode>`\ 。
|
||
|
||
若節點不在場景樹中,則無論 :ref:`process_mode<class_Node_property_process_mode>` 為何都回傳 ``false``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_create_tween:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Tween<class_Tween>` **create_tween**\ (\ ) :ref:`🔗<class_Node_method_create_tween>`
|
||
|
||
建立新的 :ref:`Tween<class_Tween>` 並綁定到本節點。
|
||
|
||
等同於以下操作:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
get_tree().create_tween().bind_node(self)
|
||
|
||
.. code-tab:: csharp
|
||
|
||
GetTree().CreateTween().BindNode(this);
|
||
|
||
|
||
|
||
該 Tween 會在下個處理影格或物理影格自動開始(依 :ref:`TweenProcessMode<enum_Tween_TweenProcessMode>` 而定)。詳見 :ref:`Tween.bind_node()<class_Tween_method_bind_node>`\ 。
|
||
|
||
\ **注意:**\ 即使節點未在 :ref:`SceneTree<class_SceneTree>` 內,本方法仍可使用。但若使用自訂 :ref:`MainLoop<class_MainLoop>`\ ,則可能失敗。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_duplicate:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **duplicate**\ (\ flags\: :ref:`int<class_int>` = 15\ ) |const| :ref:`🔗<class_Node_method_duplicate>`
|
||
|
||
Duplicates the node, returning a new node with all of its properties, signals, groups, and children copied from the original, recursively. The behavior can be tweaked through the ``flags`` (see :ref:`DuplicateFlags<enum_Node_DuplicateFlags>`). Internal nodes are not duplicated.
|
||
|
||
\ **Note:** For nodes with a :ref:`Script<class_Script>` attached, if :ref:`Object._init()<class_Object_private_method__init>` has been defined with required parameters, the duplicated node will not have a :ref:`Script<class_Script>`.
|
||
|
||
\ **Note:** By default, this method will duplicate only properties marked for serialization (i.e. using :ref:`@GlobalScope.PROPERTY_USAGE_STORAGE<class_@GlobalScope_constant_PROPERTY_USAGE_STORAGE>`, or in GDScript, :ref:`@GDScript.@export<class_@GDScript_annotation_@export>`). If you want to duplicate all properties, use :ref:`DUPLICATE_INTERNAL_STATE<class_Node_constant_DUPLICATE_INTERNAL_STATE>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_find_child:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **find_child**\ (\ pattern\: :ref:`String<class_String>`, recursive\: :ref:`bool<class_bool>` = true, owned\: :ref:`bool<class_bool>` = true\ ) |const| :ref:`🔗<class_Node_method_find_child>`
|
||
|
||
尋找本節點的第一個 :ref:`name<class_Node_property_name>` 符合 ``pattern`` 的後代節點,若未找到則回傳 ``null``\ 。比對僅針對節點名稱,\ *不*\ 比對完整路徑,使用 :ref:`String.match()<class_String_method_match>`\ ,區分大小寫。\ ``"*"`` 代表零個或多個字元,\ ``"?"`` 代表任一字元。
|
||
|
||
若 ``recursive`` 為 ``false``\ ,僅會檢查本節點的直接子節點。節點依樹狀順序檢查,先檢查第一個直接子節點,然後是其子孫,之後才檢查第二個直接子節點。搜尋時也包含內部子節點(見 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 參數)。
|
||
|
||
若 ``owned`` 為 ``true``\ ,則僅檢查有有效 :ref:`owner<class_Node_property_owner>` 的後代。
|
||
|
||
\ **注意:**\ 本方法可能非常緩慢,建議將找到的節點參考儲存於變數。或可考慮以唯一名稱搭配 :ref:`get_node()<class_Node_method_get_node>`\ (見 :ref:`unique_name_in_owner<class_Node_property_unique_name_in_owner>`\ )。
|
||
|
||
\ **注意:**\ 若要搜尋所有符合模式或型別的後代節點,請參考 :ref:`find_children()<class_Node_method_find_children>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_find_children:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Array<class_Array>`\[:ref:`Node<class_Node>`\] **find_children**\ (\ pattern\: :ref:`String<class_String>`, type\: :ref:`String<class_String>` = "", recursive\: :ref:`bool<class_bool>` = true, owned\: :ref:`bool<class_bool>` = true\ ) |const| :ref:`🔗<class_Node_method_find_children>`
|
||
|
||
尋找本節點所有名稱符合 ``pattern`` 的後代(僅比對節點名稱,\ *不*\ 比對完整路徑),比對方式採用 :ref:`String.match()<class_String_method_match>`\ ,區分大小寫。\ ``"*"`` 代表零個或多個字元,\ ``"?"`` 代表任一字元。
|
||
|
||
若 ``type`` 不為空,僅會納入繼承自 ``type`` 的節點(見 :ref:`Object.is_class()<class_Object_method_is_class>`\ )。
|
||
|
||
若 ``recursive`` 為 ``false``\ ,僅檢查本節點的直接子節點。節點依樹狀順序檢查,會先檢查第一個直接子節點,然後是其子孫,之後才檢查第二個直接子節點。搜尋時也包含內部子節點(見 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 參數)。
|
||
|
||
若 ``owned`` 為 ``true``\ ,僅檢查有有效 :ref:`owner<class_Node_property_owner>` 的後代。
|
||
|
||
\ **注意:**\ 本方法可能非常緩慢,建議將查找結果存於變數。
|
||
|
||
\ **注意:**\ 若只需搜尋符合模式的第一個後代,請參考 :ref:`find_child()<class_Node_method_find_child>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_find_parent:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **find_parent**\ (\ pattern\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_Node_method_find_parent>`
|
||
|
||
尋找本節點的第一個 :ref:`name<class_Node_property_name>` 符合 ``pattern`` 的父節點,若未找到則回傳 ``null``\ 。比對採用 :ref:`String.match()<class_String_method_match>`\ ,區分大小寫。\ ``"*"`` 代表零個或多個字元,\ ``"?"`` 代表任一字元。另見 :ref:`find_child()<class_Node_method_find_child>` 與 :ref:`find_children()<class_Node_method_find_children>`\ 。
|
||
|
||
\ **注意:**\ 此方法會沿場景樹向上搜尋,在大型或深層結構中可能較慢。建議將結果存於變數,或以唯一名稱呼叫 :ref:`get_node()<class_Node_method_get_node>`\ (參見 :ref:`unique_name_in_owner<class_Node_property_unique_name_in_owner>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_accessibility_element:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`RID<class_RID>` **get_accessibility_element**\ (\ ) |const| :ref:`🔗<class_Node_method_get_accessibility_element>`
|
||
|
||
Returns main accessibility element RID.
|
||
|
||
\ **Note:** This method should be called only during accessibility information updates (:ref:`NOTIFICATION_ACCESSIBILITY_UPDATE<class_Node_constant_NOTIFICATION_ACCESSIBILITY_UPDATE>`).
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_child:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **get_child**\ (\ idx\: :ref:`int<class_int>`, include_internal\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_Node_method_get_child>`
|
||
|
||
Fetches a child node by its index. Each child node has an index relative to its siblings (see :ref:`get_index()<class_Node_method_get_index>`). The first child is at index 0. Negative values can also be used to start from the end of the list. This method can be used in combination with :ref:`get_child_count()<class_Node_method_get_child_count>` to iterate over this node's children. If no child exists at the given index, this method returns ``null`` and an error is generated.
|
||
|
||
If ``include_internal`` is ``false``, internal children are ignored (see :ref:`add_child()<class_Node_method_add_child>`'s ``internal`` parameter).
|
||
|
||
::
|
||
|
||
# Assuming the following are children of this node, in order:
|
||
# First, Middle, Last.
|
||
|
||
var a = get_child(0).name # a is "First"
|
||
var b = get_child(1).name # b is "Middle"
|
||
var b = get_child(2).name # b is "Last"
|
||
var c = get_child(-1).name # c is "Last"
|
||
|
||
\ **Note:** To fetch a node by :ref:`NodePath<class_NodePath>`, use :ref:`get_node()<class_Node_method_get_node>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_child_count:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_child_count**\ (\ include_internal\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_Node_method_get_child_count>`
|
||
|
||
返回本節點的子節點數量。
|
||
|
||
若 ``include_internal`` 為 ``false``\ ,則不計入內部子節點(詳見 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 參數)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_children:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Array<class_Array>`\[:ref:`Node<class_Node>`\] **get_children**\ (\ include_internal\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_Node_method_get_children>`
|
||
|
||
返回本節點所有子節點的 :ref:`Array<class_Array>`\ 。
|
||
|
||
若 ``include_internal`` 為 ``false``\ ,則回傳陣列中不包含內部子節點(詳見 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 參數)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_groups:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] **get_groups**\ (\ ) |const| :ref:`🔗<class_Node_method_get_groups>`
|
||
|
||
返回本節點所屬群組名稱的 :ref:`Array<class_Array>`\ 。
|
||
|
||
\ **注意:**\ 為提升效能,群組名稱順序\ *不*\ 保證固定,可能每次專案執行皆不同,請勿依賴其順序。
|
||
|
||
\ **注意:**\ 此方法可能會回傳部分以底線(\ ``_``\ )開頭的群組名稱,這些為引擎內部用群組。為避免衝突,請勿以底線作為自訂群組開頭。若要排除內部群組,可參考下列程式片段:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 僅儲存非內部群組(StringNames 陣列)
|
||
var non_internal_groups = []
|
||
for group in get_groups():
|
||
if not str(group).begins_with("_"):
|
||
non_internal_groups.push_back(group)
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 僅儲存非內部群組(StringNames 列表)
|
||
List<string> nonInternalGroups = new List<string>();
|
||
foreach (string group in GetGroups())
|
||
{
|
||
if (!group.BeginsWith("_"))
|
||
nonInternalGroups.Add(group);
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_index:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_index**\ (\ include_internal\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_Node_method_get_index>`
|
||
|
||
返回本節點在同級節點中的順序,第一個節點索引為 ``0``\ 。詳見 :ref:`get_child()<class_Node_method_get_child>`\ 。
|
||
|
||
若 ``include_internal`` 為 ``false``\ ,則返回的索引會忽略內部子節點,第一個非內部子節點索引為 ``0``\ (詳見 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 參數)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_last_exclusive_window:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Window<class_Window>` **get_last_exclusive_window**\ (\ ) |const| :ref:`🔗<class_Node_method_get_last_exclusive_window>`
|
||
|
||
返回包含本節點的 :ref:`Window<class_Window>`\ ,或從包含該節點的視窗起始之視窗鏈中最近的獨佔子視窗。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_multiplayer_authority:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_multiplayer_authority**\ (\ ) |const| :ref:`🔗<class_Node_method_get_multiplayer_authority>`
|
||
|
||
返回本節點多人遊戲管理者的對等端 ID。詳見 :ref:`set_multiplayer_authority()<class_Node_method_set_multiplayer_authority>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_node:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **get_node**\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| :ref:`🔗<class_Node_method_get_node>`
|
||
|
||
取得節點。 :ref:`NodePath<class_NodePath>` 可為相對路徑(由本節點出發)或絕對路徑(由 :ref:`SceneTree.root<class_SceneTree_property_root>` 出發)。若 ``path`` 未指向有效節點,則產生錯誤並回傳 ``null``\ 。若對該返回值呼叫方法,會出現 *「嘗試對 null 實例呼叫 <method>。」* 錯誤。
|
||
|
||
\ **注意:**\ 以絕對路徑取得節點,僅在節點已進入場景樹時有效(參見 :ref:`is_inside_tree()<class_Node_method_is_inside_tree>`\ )。
|
||
|
||
\ **範例:**\ 假設本方法於 Character 節點下呼叫,場景樹如下:
|
||
|
||
.. code:: text
|
||
|
||
┖╴root
|
||
┠╴Character (你在這裡)
|
||
┃ ┠╴Sword
|
||
┃ ┖╴Backpack
|
||
┃ ┖╴Dagger
|
||
┠╴MyGame
|
||
┖╴Swamp
|
||
┠╴Alligator
|
||
┠╴Mosquito
|
||
┖╴Goblin
|
||
|
||
以下呼叫將獲得有效節點:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
get_node("Sword")
|
||
get_node("Backpack/Dagger")
|
||
get_node("../Swamp/Alligator")
|
||
get_node("/root/MyGame")
|
||
|
||
.. code-tab:: csharp
|
||
|
||
GetNode("Sword");
|
||
GetNode("Backpack/Dagger");
|
||
GetNode("../Swamp/Alligator");
|
||
GetNode("/root/MyGame");
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_node_and_resource:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Array<class_Array>` **get_node_and_resource**\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) :ref:`🔗<class_Node_method_get_node_and_resource>`
|
||
|
||
Fetches a node and its most nested resource as specified by the :ref:`NodePath<class_NodePath>`'s subname. Returns an :ref:`Array<class_Array>` of size ``3`` where:
|
||
|
||
- Element ``0`` is the **Node**, or ``null`` if not found;
|
||
|
||
- Element ``1`` is the subname's last nested :ref:`Resource<class_Resource>`, or ``null`` if not found;
|
||
|
||
- Element ``2`` is the remaining :ref:`NodePath<class_NodePath>`, referring to an existing, non-:ref:`Resource<class_Resource>` property (see :ref:`Object.get_indexed()<class_Object_method_get_indexed>`).
|
||
|
||
\ **Example:** Assume that the child's :ref:`Sprite2D.texture<class_Sprite2D_property_texture>` has been assigned an :ref:`AtlasTexture<class_AtlasTexture>`:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
var a = get_node_and_resource("Area2D/Sprite2D")
|
||
print(a[0].name) # Prints Sprite2D
|
||
print(a[1]) # Prints <null>
|
||
print(a[2]) # Prints ^""
|
||
|
||
var b = get_node_and_resource("Area2D/Sprite2D:texture:atlas")
|
||
print(b[0].name) # Prints Sprite2D
|
||
print(b[1].get_class()) # Prints AtlasTexture
|
||
print(b[2]) # Prints ^""
|
||
|
||
var c = get_node_and_resource("Area2D/Sprite2D:texture:atlas:region")
|
||
print(c[0].name) # Prints Sprite2D
|
||
print(c[1].get_class()) # Prints AtlasTexture
|
||
print(c[2]) # Prints ^":region"
|
||
|
||
.. code-tab:: csharp
|
||
|
||
var a = GetNodeAndResource(NodePath("Area2D/Sprite2D"));
|
||
GD.Print(a[0].Name); // Prints Sprite2D
|
||
GD.Print(a[1]); // Prints <null>
|
||
GD.Print(a[2]); // Prints ^"
|
||
|
||
var b = GetNodeAndResource(NodePath("Area2D/Sprite2D:texture:atlas"));
|
||
GD.Print(b[0].name); // Prints Sprite2D
|
||
GD.Print(b[1].get_class()); // Prints AtlasTexture
|
||
GD.Print(b[2]); // Prints ^""
|
||
|
||
var c = GetNodeAndResource(NodePath("Area2D/Sprite2D:texture:atlas:region"));
|
||
GD.Print(c[0].name); // Prints Sprite2D
|
||
GD.Print(c[1].get_class()); // Prints AtlasTexture
|
||
GD.Print(c[2]); // Prints ^":region"
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_node_or_null:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **get_node_or_null**\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| :ref:`🔗<class_Node_method_get_node_or_null>`
|
||
|
||
依 :ref:`NodePath<class_NodePath>` 取得節點。類似 :ref:`get_node()<class_Node_method_get_node>`\ ,但若 ``path`` 未指向有效節點時不會產生錯誤。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_node_rpc_config:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Variant<class_Variant>` **get_node_rpc_config**\ (\ ) |const| :ref:`🔗<class_Node_method_get_node_rpc_config>`
|
||
|
||
Returns a :ref:`Dictionary<class_Dictionary>` mapping method names to their RPC configuration defined for this node using :ref:`rpc_config()<class_Node_method_rpc_config>`.
|
||
|
||
\ **Note:** This method only returns the RPC configuration assigned via :ref:`rpc_config()<class_Node_method_rpc_config>`. See :ref:`Script.get_rpc_config()<class_Script_method_get_rpc_config>` to retrieve the RPCs defined by the :ref:`Script<class_Script>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_orphan_node_ids:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Array<class_Array>`\[:ref:`int<class_int>`\] **get_orphan_node_ids**\ (\ ) |static| :ref:`🔗<class_Node_method_get_orphan_node_ids>`
|
||
|
||
Returns object IDs of all orphan nodes (nodes outside the :ref:`SceneTree<class_SceneTree>`). Used for debugging.
|
||
|
||
\ **Note:** :ref:`get_orphan_node_ids()<class_Node_method_get_orphan_node_ids>` only works in debug builds. When called in a project exported in release mode, :ref:`get_orphan_node_ids()<class_Node_method_get_orphan_node_ids>` will return an empty array.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_parent:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Node<class_Node>` **get_parent**\ (\ ) |const| :ref:`🔗<class_Node_method_get_parent>`
|
||
|
||
返回本節點的父節點;若無父節點則回傳 ``null``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_path:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`NodePath<class_NodePath>` **get_path**\ (\ ) |const| :ref:`🔗<class_Node_method_get_path>`
|
||
|
||
傳回節點相對於 :ref:`SceneTree.root<class_SceneTree_property_root>` 的絕對路徑。若節點不在場景樹內,則此方法會失敗並傳回空的 :ref:`NodePath<class_NodePath>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_path_to:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`NodePath<class_NodePath>` **get_path_to**\ (\ node\: :ref:`Node<class_Node>`, use_unique_path\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_Node_method_get_path_to>`
|
||
|
||
傳回從此節點到指定 ``node`` 的相對 :ref:`NodePath<class_NodePath>`\ 。兩個節點必須位於同一個 :ref:`SceneTree<class_SceneTree>` 或場景階層中,否則此方法會失敗並傳回空的 :ref:`NodePath<class_NodePath>`\ 。
|
||
|
||
若 ``use_unique_path`` 為 ``true``\ ,則會回傳包含此節點唯一名稱的最短路徑(見 :ref:`unique_name_in_owner<class_Node_property_unique_name_in_owner>`\ )。
|
||
|
||
\ **注意:** 如果你獲得的相對路徑是從唯一節點開始,則此路徑可能會因加上唯一節點的名稱而比一般的相對路徑還長。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_physics_process_delta_time:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`float<class_float>` **get_physics_process_delta_time**\ (\ ) |const| :ref:`🔗<class_Node_method_get_physics_process_delta_time>`
|
||
|
||
傳回自上次物理回呼以來經過的時間(秒)。這個值等同於 :ref:`_physics_process()<class_Node_private_method__physics_process>` 的 ``delta`` 參數,除非變更 :ref:`Engine.physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`\ ,否則執行時通常是一致的。另請參閱 :ref:`NOTIFICATION_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>`\ 。
|
||
|
||
\ **注意:** 若目前畫格率低於 :ref:`Engine.physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` / :ref:`Engine.max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` FPS,回傳值會大於預期。這是為了避免因每格物理步數增加導致效能下降(即所謂的「死亡螺旋」)。這個行為會影響 :ref:`_process()<class_Node_private_method__process>` 與 :ref:`_physics_process()<class_Node_private_method__physics_process>`\ 。因此,請避免用 ``delta`` 來計算真實世界的時間。請改用 :ref:`Time<class_Time>` 單例的方法(如 :ref:`Time.get_ticks_usec()<class_Time_method_get_ticks_usec>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_process_delta_time:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`float<class_float>` **get_process_delta_time**\ (\ ) |const| :ref:`🔗<class_Node_method_get_process_delta_time>`
|
||
|
||
傳回自上次處理回呼以來經過的時間(秒)。這個值等同於 :ref:`_process()<class_Node_private_method__process>` 的 ``delta`` 參數,每個畫格可能會不同。另請參閱 :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ 。
|
||
|
||
\ **注意:** 若目前畫格率低於 :ref:`Engine.physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` / :ref:`Engine.max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` FPS,回傳值會大於預期。這是為了避免因每格物理步數增加導致效能下降(即所謂的「死亡螺旋」)。這個行為會影響 :ref:`_process()<class_Node_private_method__process>` 與 :ref:`_physics_process()<class_Node_private_method__physics_process>`\ 。因此,請避免用 ``delta`` 來計算真實世界的時間。請改用 :ref:`Time<class_Time>` 單例的方法(如 :ref:`Time.get_ticks_usec()<class_Time_method_get_ticks_usec>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_scene_instance_load_placeholder:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **get_scene_instance_load_placeholder**\ (\ ) |const| :ref:`🔗<class_Node_method_get_scene_instance_load_placeholder>`
|
||
|
||
若此節點為實例載入預留位,則傳回 ``true``\ 。請參閱 :ref:`InstancePlaceholder<class_InstancePlaceholder>` 及 :ref:`set_scene_instance_load_placeholder()<class_Node_method_set_scene_instance_load_placeholder>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_tree:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`SceneTree<class_SceneTree>` **get_tree**\ (\ ) |const| :ref:`🔗<class_Node_method_get_tree>`
|
||
|
||
傳回包含此節點的 :ref:`SceneTree<class_SceneTree>`\ 。若此節點不在樹內,則會產生錯誤並傳回 ``null``\ 。另請參閱 :ref:`is_inside_tree()<class_Node_method_is_inside_tree>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_tree_string:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **get_tree_string**\ (\ ) :ref:`🔗<class_Node_method_get_tree_string>`
|
||
|
||
傳回樹狀結構的字串,主要用於除錯。本版本顯示相對於目前節點的路徑,適合複製/貼上至 :ref:`get_node()<class_Node_method_get_node>` 函式,也可用於遊戲 UI/UX。
|
||
|
||
範例輸出:
|
||
|
||
.. code:: text
|
||
|
||
TheGame
|
||
TheGame/Menu
|
||
TheGame/Menu/Label
|
||
TheGame/Menu/Camera2D
|
||
TheGame/SplashScreen
|
||
TheGame/SplashScreen/Camera2D
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_tree_string_pretty:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **get_tree_string_pretty**\ (\ ) :ref:`🔗<class_Node_method_get_tree_string_pretty>`
|
||
|
||
類似於 :ref:`get_tree_string()<class_Node_method_get_tree_string>`\ ,但本方法傳回更圖形化的樹狀結構字串,與場景面板顯示相似,適合檢查大型樹狀結構。
|
||
|
||
範例輸出:
|
||
|
||
.. code:: text
|
||
|
||
┖╴TheGame
|
||
┠╴Menu
|
||
┃ ┠╴Label
|
||
┃ ┖╴Camera2D
|
||
┖╴SplashScreen
|
||
┖╴Camera2D
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_viewport:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Viewport<class_Viewport>` **get_viewport**\ (\ ) |const| :ref:`🔗<class_Node_method_get_viewport>`
|
||
|
||
若節點在樹內,則傳回最接近的 :ref:`Viewport<class_Viewport>` 上層節點;否則傳回 ``null``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_get_window:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Window<class_Window>` **get_window**\ (\ ) |const| :ref:`🔗<class_Node_method_get_window>`
|
||
|
||
傳回包含此節點的 :ref:`Window<class_Window>`\ 。若節點位於主視窗,等同於取得根節點(\ ``get_tree().get_root()``\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_has_node:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_node**\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| :ref:`🔗<class_Node_method_has_node>`
|
||
|
||
若 ``path`` 指向有效節點則傳回 ``true``\ 。另請參閱 :ref:`get_node()<class_Node_method_get_node>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_has_node_and_resource:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_node_and_resource**\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |const| :ref:`🔗<class_Node_method_has_node_and_resource>`
|
||
|
||
若 ``path`` 指向有效節點,且其子名稱為有效 :ref:`Resource<class_Resource>`\ (例如 ``Area2D/CollisionShape2D:shape``\ ),則傳回 ``true``\ 。非 :ref:`Resource<class_Resource>` 類型的屬性(如節點或其他 :ref:`Variant<class_Variant>` 類型)不予考慮。另請參閱 :ref:`get_node_and_resource()<class_Node_method_get_node_and_resource>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_ancestor_of:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_ancestor_of**\ (\ node\: :ref:`Node<class_Node>`\ ) |const| :ref:`🔗<class_Node_method_is_ancestor_of>`
|
||
|
||
若給定的 ``node`` 為此節點的直接或間接子節點,則傳回 ``true``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_displayed_folded:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_displayed_folded**\ (\ ) |const| :ref:`🔗<class_Node_method_is_displayed_folded>`
|
||
|
||
若此節點在場景面板中被折疊,則傳回 ``true``\ 。此方法主要供編輯器外掛與工具使用。另請參閱 :ref:`set_display_folded()<class_Node_method_set_display_folded>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_editable_instance:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_editable_instance**\ (\ node\: :ref:`Node<class_Node>`\ ) |const| :ref:`🔗<class_Node_method_is_editable_instance>`
|
||
|
||
若 ``node`` 針對此節點啟用了可編輯子節點,則傳回 ``true``\ 。此方法主要供編輯器外掛與工具使用。另請參閱 :ref:`set_editable_instance()<class_Node_method_set_editable_instance>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_greater_than:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_greater_than**\ (\ node\: :ref:`Node<class_Node>`\ ) |const| :ref:`🔗<class_Node_method_is_greater_than>`
|
||
|
||
若給定 ``node`` 在場景階層中出現於本節點之後,則傳回 ``true``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_in_group:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_in_group**\ (\ group\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Node_method_is_in_group>`
|
||
|
||
若此節點已加入指定 ``group``\ ,則傳回 ``true``\ 。詳見 :ref:`add_to_group()<class_Node_method_add_to_group>`\ 、\ :ref:`remove_from_group()<class_Node_method_remove_from_group>` 及 :ref:`SceneTree<class_SceneTree>` 的群組方法說明。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_inside_tree:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_inside_tree**\ (\ ) |const| :ref:`🔗<class_Node_method_is_inside_tree>`
|
||
|
||
若此節點目前位於 :ref:`SceneTree<class_SceneTree>` 中,則傳回 ``true``\ 。另請參閱 :ref:`get_tree()<class_Node_method_get_tree>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_multiplayer_authority:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_multiplayer_authority**\ (\ ) |const| :ref:`🔗<class_Node_method_is_multiplayer_authority>`
|
||
|
||
若本地系統為此節點的多人遊戲權限方,則傳回 ``true``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_node_ready:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_node_ready**\ (\ ) |const| :ref:`🔗<class_Node_method_is_node_ready>`
|
||
|
||
若此節點已就緒(即已進入場景樹且所有子節點皆初始化),則傳回 ``true``\ 。
|
||
|
||
\ :ref:`request_ready()<class_Node_method_request_ready>` 會將其重設為 ``false``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_part_of_edited_scene:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_part_of_edited_scene**\ (\ ) |const| :ref:`🔗<class_Node_method_is_part_of_edited_scene>`
|
||
|
||
若此節點屬於目前在編輯器中開啟的場景,則傳回 ``true``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_physics_interpolated:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_physics_interpolated**\ (\ ) |const| :ref:`🔗<class_Node_method_is_physics_interpolated>`
|
||
|
||
若已為此節點啟用物理內插(見 :ref:`physics_interpolation_mode<class_Node_property_physics_interpolation_mode>`\ ),則返回 ``true``\ 。
|
||
|
||
\ **注意:**\ 只有同時啟用此旗標\ **且**\ :ref:`SceneTree<class_SceneTree>` 內啟用了物理內插時,內插才會生效。可用 :ref:`is_physics_interpolated_and_enabled()<class_Node_method_is_physics_interpolated_and_enabled>` 測試。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_physics_interpolated_and_enabled:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_physics_interpolated_and_enabled**\ (\ ) |const| :ref:`🔗<class_Node_method_is_physics_interpolated_and_enabled>`
|
||
|
||
若已啟用物理內插(見 :ref:`physics_interpolation_mode<class_Node_property_physics_interpolation_mode>`\ )\ **且**\ :ref:`SceneTree<class_SceneTree>` 內也有啟用,則返回 ``true``\ 。
|
||
|
||
這是 :ref:`is_physics_interpolated()<class_Node_method_is_physics_interpolated>` 的便利版本,會同時檢查全域設定。
|
||
|
||
請參閱 :ref:`SceneTree.physics_interpolation<class_SceneTree_property_physics_interpolation>` 及 :ref:`ProjectSettings.physics/common/physics_interpolation<class_ProjectSettings_property_physics/common/physics_interpolation>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_physics_processing:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_physics_processing**\ (\ ) |const| :ref:`🔗<class_Node_method_is_physics_processing>`
|
||
|
||
若啟用物理處理則傳回 ``true``\ (見 :ref:`set_physics_process()<class_Node_method_set_physics_process>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_physics_processing_internal:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_physics_processing_internal**\ (\ ) |const| :ref:`🔗<class_Node_method_is_physics_processing_internal>`
|
||
|
||
若啟用內部物理處理則傳回 ``true``\ (見 :ref:`set_physics_process_internal()<class_Node_method_set_physics_process_internal>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_processing:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_processing**\ (\ ) |const| :ref:`🔗<class_Node_method_is_processing>`
|
||
|
||
若啟用處理則傳回 ``true``\ (見 :ref:`set_process()<class_Node_method_set_process>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_processing_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_processing_input**\ (\ ) |const| :ref:`🔗<class_Node_method_is_processing_input>`
|
||
|
||
若節點正在處理輸入則傳回 ``true``\ (見 :ref:`set_process_input()<class_Node_method_set_process_input>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_processing_internal:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_processing_internal**\ (\ ) |const| :ref:`🔗<class_Node_method_is_processing_internal>`
|
||
|
||
若啟用內部處理則傳回 ``true``\ (見 :ref:`set_process_internal()<class_Node_method_set_process_internal>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_processing_shortcut_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_processing_shortcut_input**\ (\ ) |const| :ref:`🔗<class_Node_method_is_processing_shortcut_input>`
|
||
|
||
若節點正在處理快捷鍵則傳回 ``true``\ (見 :ref:`set_process_shortcut_input()<class_Node_method_set_process_shortcut_input>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_processing_unhandled_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_processing_unhandled_input**\ (\ ) |const| :ref:`🔗<class_Node_method_is_processing_unhandled_input>`
|
||
|
||
若節點正在處理未處理的輸入則傳回 ``true``\ (見 :ref:`set_process_unhandled_input()<class_Node_method_set_process_unhandled_input>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_is_processing_unhandled_key_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_processing_unhandled_key_input**\ (\ ) |const| :ref:`🔗<class_Node_method_is_processing_unhandled_key_input>`
|
||
|
||
若節點正在處理未處理的按鍵輸入則傳回 ``true``\ (見 :ref:`set_process_unhandled_key_input()<class_Node_method_set_process_unhandled_key_input>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_move_child:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **move_child**\ (\ child_node\: :ref:`Node<class_Node>`, to_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Node_method_move_child>`
|
||
|
||
將 ``child_node`` 移動至指定索引位置。節點索引為其在兄弟節點中的順序,若 ``to_index`` 為負數,則從末尾倒數。另請參閱 :ref:`get_child()<class_Node_method_get_child>` 及 :ref:`get_index()<class_Node_method_get_index>`\ 。
|
||
|
||
\ **注意:** 多個引擎回呼(如 :ref:`_ready()<class_Node_private_method__ready>`\ 、\ :ref:`_process()<class_Node_private_method__process>` 等)及透過 :ref:`propagate_notification()<class_Node_method_propagate_notification>` 傳送的通知,處理順序皆受樹狀順序影響。\ :ref:`CanvasItem<class_CanvasItem>` 節點也會依此順序繪製。另請參閱 :ref:`process_priority<class_Node_property_process_priority>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_notify_deferred_thread_group:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **notify_deferred_thread_group**\ (\ what\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Node_method_notify_deferred_thread_group>`
|
||
|
||
類似於 :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>`\ ,但用於通知。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_notify_thread_safe:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **notify_thread_safe**\ (\ what\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Node_method_notify_thread_safe>`
|
||
|
||
類似於 :ref:`call_thread_safe()<class_Node_method_call_thread_safe>`\ ,但用於通知。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_print_orphan_nodes:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **print_orphan_nodes**\ (\ ) |static| :ref:`🔗<class_Node_method_print_orphan_nodes>`
|
||
|
||
Prints all orphan nodes (nodes outside the :ref:`SceneTree<class_SceneTree>`). Useful for debugging.
|
||
|
||
\ **Note:** This method only works in debug builds. It does nothing in a project exported in release mode.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_print_tree:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **print_tree**\ (\ ) :ref:`🔗<class_Node_method_print_tree>`
|
||
|
||
遞迴印出節點及其所有子節點至主控台。節點無需位於樹中。本方法輸出相對於本節點的 :ref:`NodePath<class_NodePath>`\ ,適合複製/貼上至 :ref:`get_node()<class_Node_method_get_node>`\ 。另請參閱 :ref:`print_tree_pretty()<class_Node_method_print_tree_pretty>`\ 。
|
||
|
||
範例輸出:
|
||
|
||
.. code:: text
|
||
|
||
.
|
||
Menu
|
||
Menu/Label
|
||
Menu/Camera2D
|
||
SplashScreen
|
||
SplashScreen/Camera2D
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_print_tree_pretty:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **print_tree_pretty**\ (\ ) :ref:`🔗<class_Node_method_print_tree_pretty>`
|
||
|
||
遞迴印出節點和其子節點至主控台,無需在樹內。類似於 :ref:`print_tree()<class_Node_method_print_tree>`\ ,但圖形化格式類似於編輯器場景面板,適合檢查大型樹狀結構。
|
||
|
||
範例輸出:
|
||
|
||
.. code:: text
|
||
|
||
┖╴TheGame
|
||
┠╴Menu
|
||
┃ ┠╴Label
|
||
┃ ┖╴Camera2D
|
||
┖╴SplashScreen
|
||
┖╴Camera2D
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_propagate_call:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **propagate_call**\ (\ method\: :ref:`StringName<class_StringName>`, args\: :ref:`Array<class_Array>` = [], parent_first\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Node_method_propagate_call>`
|
||
|
||
遞迴於本節點及其所有子節點上呼叫指定 ``method``\ ,並傳入 ``args`` 作為參數。
|
||
|
||
若 ``parent_first`` 為 ``true``\ ,則會先於本節點呼叫,接著再對所有子節點呼叫。若為 ``false``\ ,則會先呼叫子節點上的方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_propagate_notification:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **propagate_notification**\ (\ what\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Node_method_propagate_notification>`
|
||
|
||
於本節點及其所有子節點遞迴呼叫 :ref:`Object.notification()<class_Object_method_notification>`\ ,並傳入 ``what`` 參數。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_queue_accessibility_update:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **queue_accessibility_update**\ (\ ) :ref:`🔗<class_Node_method_queue_accessibility_update>`
|
||
|
||
Queues an accessibility information update for this node.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_queue_free:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **queue_free**\ (\ ) :ref:`🔗<class_Node_method_queue_free>`
|
||
|
||
將此節點排程於目前畫格結束時刪除。刪除時,其所有子節點也會一併移除,對該節點及其子節點的所有參考將失效。
|
||
|
||
和 :ref:`Object.free()<class_Object_method_free>` 不同,queue_free 並非立即刪除,於刪除前仍可存取此節點。多次呼叫 :ref:`queue_free()<class_Node_method_queue_free>` 亦安全。可用 :ref:`Object.is_queued_for_deletion()<class_Object_method_is_queued_for_deletion>` 檢查畫格結束時是否會刪除。
|
||
|
||
\ **注意:** 節點僅會於所有其他延遲呼叫結束後才釋放。此方式與用 :ref:`Object.call_deferred()<class_Object_method_call_deferred>` 執行 :ref:`Object.free()<class_Object_method_free>` 不全然相同。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_remove_child:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_child**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_Node_method_remove_child>`
|
||
|
||
移除子節點 ``node``\ 。該節點及其所有子節點\ **不會**\ 被刪除,如需刪除請參閱 :ref:`queue_free()<class_Node_method_queue_free>`\ 。
|
||
|
||
\ **注意:**\ 當本節點位於樹內時,如果被移除的 ``node``\ (或其後代)的 :ref:`owner<class_Node_property_owner>` 不再是祖先,則此方法會將其 :ref:`owner<class_Node_property_owner>` 設為 ``null``\ (見 :ref:`is_ancestor_of()<class_Node_method_is_ancestor_of>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_remove_from_group:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_from_group**\ (\ group\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Node_method_remove_from_group>`
|
||
|
||
將節點自指定 ``group`` 移除。若節點不在該群組則無動作。詳見說明及 :ref:`SceneTree<class_SceneTree>` 的群組方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_reparent:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **reparent**\ (\ new_parent\: :ref:`Node<class_Node>`, keep_global_transform\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_Node_method_reparent>`
|
||
|
||
將本 **Node** 的父節點變更為 ``new_parent``\ 。此節點必須已有父節點。若 :ref:`owner<class_Node_property_owner>` 仍可從新位置存取,則會保留。
|
||
|
||
若 ``keep_global_transform`` 為 ``true``\ ,則支援的情況下會保留節點全域轉換。\ :ref:`Node2D<class_Node2D>`\ 、\ :ref:`Node3D<class_Node3D>` 與 :ref:`Control<class_Control>` 支援此參數(\ :ref:`Control<class_Control>` 僅保留位置)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_replace_by:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **replace_by**\ (\ node\: :ref:`Node<class_Node>`, keep_groups\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Node_method_replace_by>`
|
||
|
||
以給定的 ``node`` 取代本節點。本節點的所有子節點皆會移動到 ``node``\ 。
|
||
|
||
若 ``keep_groups`` 為 ``true``\ ,則 ``node`` 會加入被取代節點所在的所有群組(見 :ref:`add_to_group()<class_Node_method_add_to_group>`\ )。
|
||
|
||
\ **警告:** 被取代節點會自樹中移除,但\ **不會**\ 自動刪除。為避免記憶體外洩,請將其儲存於變數或用 :ref:`Object.free()<class_Object_method_free>` 釋放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_request_ready:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **request_ready**\ (\ ) :ref:`🔗<class_Node_method_request_ready>`
|
||
|
||
要求下次節點進入樹時再次呼叫 :ref:`_ready()<class_Node_private_method__ready>`\ 。不會\ **立即**\ 呼叫 :ref:`_ready()<class_Node_private_method__ready>`\ 。
|
||
|
||
\ **注意:** 此方法僅影響目前節點。如需讓其子節點也重新呼叫 ready,必須對每個子節點分別呼叫。當節點及其子節點再次進入樹時, :ref:`_ready()<class_Node_private_method__ready>` 的呼叫順序與一般情況相同。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_reset_physics_interpolation:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **reset_physics_interpolation**\ (\ ) :ref:`🔗<class_Node_method_reset_physics_interpolation>`
|
||
|
||
啟用物理內插時,若將節點移動到截然不同的位置(如場景中重新擺放物件),可能會產生物件從舊位置到新位置的可見異常。
|
||
|
||
可呼叫本方法暫時停用內插,直到物理步驟完成以避免此現象。
|
||
|
||
節點及其所有子節點會遞迴收到 :ref:`NOTIFICATION_RESET_PHYSICS_INTERPOLATION<class_Node_constant_NOTIFICATION_RESET_PHYSICS_INTERPOLATION>` 通知。
|
||
|
||
\ **注意:**\ 本函式應於移動節點\ **之後**\ 呼叫,而非之前。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_rpc:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Error<enum_@GlobalScope_Error>` **rpc**\ (\ method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| :ref:`🔗<class_Node_method_rpc>`
|
||
|
||
將指定 ``method`` 的遠端程序呼叫請求發送給網路上的對等端(及本地端),可傳送額外參數給 RPC 所呼叫的方法。只有具有相同 :ref:`NodePath<class_NodePath>`\ (包含完全相同 :ref:`name<class_Node_property_name>`\ )的節點會收到此呼叫。行為取決於該方法的 RPC 設定(見 :ref:`rpc_config()<class_Node_method_rpc_config>` 及 :ref:`@GDScript.@rpc<class_@GDScript_annotation_@rpc>`\ )。預設情況下,方法不會對 RPC 開放。
|
||
|
||
成功時回傳 :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>`\ ,若參數不符則回傳 :ref:`@GlobalScope.ERR_INVALID_PARAMETER<class_@GlobalScope_constant_ERR_INVALID_PARAMETER>`\ ,若無法取得 :ref:`multiplayer<class_Node_property_multiplayer>`\ (例如節點不在樹內)則回傳 :ref:`@GlobalScope.ERR_UNCONFIGURED<class_@GlobalScope_constant_ERR_UNCONFIGURED>`\ ,若連線不可用則回傳 :ref:`@GlobalScope.ERR_CONNECTION_ERROR<class_@GlobalScope_constant_ERR_CONNECTION_ERROR>`\ 。
|
||
|
||
\ **注意:** 僅於收到 :ref:`MultiplayerAPI<class_MultiplayerAPI>` 的 :ref:`MultiplayerAPI.connected_to_server<class_MultiplayerAPI_signal_connected_to_server>` 訊號後,才能安全於客戶端使用 RPC。你也需追蹤連線狀態,可透過 :ref:`MultiplayerAPI<class_MultiplayerAPI>` 的訊號(如 :ref:`MultiplayerAPI.server_disconnected<class_MultiplayerAPI_signal_server_disconnected>`\ )或檢查 ``get_multiplayer().peer.get_connection_status() == CONNECTION_CONNECTED``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_rpc_config:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **rpc_config**\ (\ method\: :ref:`StringName<class_StringName>`, config\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_Node_method_rpc_config>`
|
||
|
||
更改指定 ``method`` 的 RPC 設定。\ ``config`` 可設為 ``null`` 以停用(預設),或為包含以下項目的 :ref:`Dictionary<class_Dictionary>`\ :
|
||
|
||
- ``rpc_mode``\ :見 :ref:`RPCMode<enum_MultiplayerAPI_RPCMode>`\ ;
|
||
|
||
- ``transfer_mode``\ :見 :ref:`TransferMode<enum_MultiplayerPeer_TransferMode>`\ ;
|
||
|
||
- ``call_local``\ :若設為 ``true``\ ,方法也會在本地呼叫;
|
||
|
||
- ``channel``\ :指定傳送 RPC 的頻道 :ref:`int<class_int>`\ 。
|
||
|
||
\ **注意:** 在 GDScript,這對應於 :ref:`@GDScript.@rpc<class_@GDScript_annotation_@rpc>` 標註,可接受不同參數(如 ``@rpc(any)``\ 、\ ``@rpc(authority)``...)。另請參考 :doc:`高階多人連線 <../tutorials/networking/high_level_multiplayer>` 教學。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_rpc_id:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Error<enum_@GlobalScope_Error>` **rpc_id**\ (\ peer_id\: :ref:`int<class_int>`, method\: :ref:`StringName<class_StringName>`, ...\ ) |vararg| :ref:`🔗<class_Node_method_rpc_id>`
|
||
|
||
將 :ref:`rpc()<class_Node_method_rpc>` 呼叫發送給指定 ``peer_id`` 的對等端(見 :ref:`MultiplayerPeer.set_target_peer()<class_MultiplayerPeer_method_set_target_peer>`\ )。
|
||
|
||
成功時回傳 :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>`\ ,若參數不符則回傳 :ref:`@GlobalScope.ERR_INVALID_PARAMETER<class_@GlobalScope_constant_ERR_INVALID_PARAMETER>`\ ,若無法取得節點 :ref:`multiplayer<class_Node_property_multiplayer>`\ (如節點不在樹內)則回傳 :ref:`@GlobalScope.ERR_UNCONFIGURED<class_@GlobalScope_constant_ERR_UNCONFIGURED>`\ ,若連線不可用則回傳 :ref:`@GlobalScope.ERR_CONNECTION_ERROR<class_@GlobalScope_constant_ERR_CONNECTION_ERROR>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_deferred_thread_group:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_deferred_thread_group**\ (\ property\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_Node_method_set_deferred_thread_group>`
|
||
|
||
類似於 :ref:`call_deferred_thread_group()<class_Node_method_call_deferred_thread_group>`\ ,但用於設定屬性。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_display_folded:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_display_folded**\ (\ fold\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_display_folded>`
|
||
|
||
若設為 ``true``\ ,此節點將於場景面板中顯示為折疊狀態,其所有子節點亦會隱藏。此方法主要供編輯器外掛與工具使用,但於發行版亦可用。另請參閱 :ref:`is_displayed_folded()<class_Node_method_is_displayed_folded>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_editable_instance:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_editable_instance**\ (\ node\: :ref:`Node<class_Node>`, is_editable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_editable_instance>`
|
||
|
||
設為 ``true`` 時,允許 ``node`` 擁有的所有節點在場景面板中可用且可編輯,即使其 :ref:`owner<class_Node_property_owner>` 不是場景根節點。此方法主要供編輯器外掛與工具使用,但於發行版亦可用。另請參閱 :ref:`is_editable_instance()<class_Node_method_is_editable_instance>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_multiplayer_authority:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_multiplayer_authority**\ (\ id\: :ref:`int<class_int>`, recursive\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_Node_method_set_multiplayer_authority>`
|
||
|
||
將此節點的多人遊戲權限設為指定對等端(peer)ID 的對等端。多人遊戲權限是指在網路上對此節點具有權限的對等端。預設為對等端 ID 1(伺服器)。可與 :ref:`rpc_config()<class_Node_method_rpc_config>` 及 :ref:`MultiplayerAPI<class_MultiplayerAPI>` 搭配使用。
|
||
|
||
若 ``recursive`` 為 ``true``\ ,則會遞迴地將此權限設定為本節點所有子節點。
|
||
|
||
\ **警告:**\ 這個操作\ **不會**\ 自動將新權限同步給其他對等端,需由開發者自行處理。你可以用 :ref:`MultiplayerSpawner.spawn_function<class_MultiplayerSpawner_property_spawn_function>`\ 、RPC 或 :ref:`MultiplayerSynchronizer<class_MultiplayerSynchronizer>` 來傳遞新權限資訊。此外,父節點的權限\ **不會**\ 自動傳遞給新加入的子節點。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_physics_process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_physics_process**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_physics_process>`
|
||
|
||
若設為 ``true``\ ,則啟用物理(固定更新率)處理。當節點處於處理狀態時,會以固定間隔(通常為 60 FPS,可透過 :ref:`Engine.physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` 更改)收到 :ref:`NOTIFICATION_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_PHYSICS_PROCESS>`\ ,並在有 :ref:`_physics_process()<class_Node_private_method__physics_process>` 回呼時呼叫之。
|
||
|
||
\ **注意:**\ 若有覆寫 :ref:`_physics_process()<class_Node_private_method__physics_process>`\ ,此狀態會在 :ref:`_ready()<class_Node_private_method__ready>` 被呼叫前自動啟用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_physics_process_internal:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_physics_process_internal**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_physics_process_internal>`
|
||
|
||
若設為 ``true``\ ,則啟用本節點的內部物理處理。內部物理處理獨立於一般的 :ref:`_physics_process()<class_Node_private_method__physics_process>` 呼叫,部分節點會用於確保即使節點暫停或腳本已關閉物理處理(\ :ref:`set_physics_process()<class_Node_method_set_physics_process>`\ )時依然能正常運作。
|
||
|
||
\ **警告:**\ 內建節點仰賴這種內部邏輯運作,停用後可能會造成非預期行為。請確定你明白用途才操作。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_process**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_process>`
|
||
|
||
若設為 ``true``\ ,則啟用處理。當節點被處理時,每個繪製影格都會收到 :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ (若有,則呼叫 :ref:`_process()<class_Node_private_method__process>` 回呼)。
|
||
|
||
\ **注意:**\ 若有覆寫 :ref:`_process()<class_Node_private_method__process>`\ ,此狀態會在 :ref:`_ready()<class_Node_private_method__ready>` 被呼叫前自動啟用。
|
||
|
||
\ **注意:**\ 這個方法僅影響 :ref:`_process()<class_Node_private_method__process>` 回呼,不會影響像 :ref:`_physics_process()<class_Node_private_method__physics_process>` 這類其他回呼。若欲完全停用節點的所有處理,請將 :ref:`process_mode<class_Node_property_process_mode>` 設為 :ref:`PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_process_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_process_input**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_process_input>`
|
||
|
||
若設為 ``true``\ ,則啟用輸入處理。
|
||
|
||
\ **注意:**\ 若有覆寫 :ref:`_input()<class_Node_private_method__input>`\ ,此狀態會在 :ref:`_ready()<class_Node_private_method__ready>` 被呼叫前自動啟用。對於像 :ref:`Button<class_Button>`\ 、\ :ref:`TextEdit<class_TextEdit>` 等 GUI 控制元件,輸入處理預設已啟用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_process_internal:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_process_internal**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_process_internal>`
|
||
|
||
若設為 ``true``\ ,則啟用本節點的內部處理。內部處理獨立於一般的 :ref:`_process()<class_Node_private_method__process>` 呼叫,部分節點會用於確保即使節點暫停或因腳本停用處理(\ :ref:`set_process()<class_Node_method_set_process>`\ )時依然能正常運作。
|
||
|
||
\ **警告:**\ 內建節點仰賴這種內部邏輯運作,停用後可能會造成非預期行為。請確定你明白用途才操作。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_process_shortcut_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_process_shortcut_input**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_process_shortcut_input>`
|
||
|
||
若設為 ``true``\ ,則啟用本節點的快捷鍵處理。
|
||
|
||
\ **注意:**\ 若有覆寫 :ref:`_shortcut_input()<class_Node_private_method__shortcut_input>`\ ,此狀態會在 :ref:`_ready()<class_Node_private_method__ready>` 被呼叫前自動啟用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_process_unhandled_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_process_unhandled_input**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_process_unhandled_input>`
|
||
|
||
若設為 ``true``\ ,則啟用未處理輸入的處理。這會讓節點收到所有尚未被處理的輸入(通常由 :ref:`Control<class_Control>` 類元件處理)。
|
||
|
||
\ **注意:**\ 若有覆寫 :ref:`_unhandled_input()<class_Node_private_method__unhandled_input>`\ ,此狀態會在 :ref:`_ready()<class_Node_private_method__ready>` 被呼叫前自動啟用。未處理輸入對於 :ref:`Button<class_Button>`\ 、\ :ref:`TextEdit<class_TextEdit>` 等 GUI 控制元件已預設啟用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_process_unhandled_key_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_process_unhandled_key_input**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_process_unhandled_key_input>`
|
||
|
||
若設為 ``true``\ ,則啟用未處理鍵盤輸入的處理。
|
||
|
||
\ **注意:**\ 若有覆寫 :ref:`_unhandled_key_input()<class_Node_private_method__unhandled_key_input>`\ ,此狀態會在 :ref:`_ready()<class_Node_private_method__ready>` 被呼叫前自動啟用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_scene_instance_load_placeholder:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_scene_instance_load_placeholder**\ (\ load_placeholder\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Node_method_set_scene_instance_load_placeholder>`
|
||
|
||
If set to ``true``, the node becomes an :ref:`InstancePlaceholder<class_InstancePlaceholder>` when packed and instantiated from a :ref:`PackedScene<class_PackedScene>`. See also :ref:`get_scene_instance_load_placeholder()<class_Node_method_get_scene_instance_load_placeholder>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_thread_safe:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_thread_safe**\ (\ property\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_Node_method_set_thread_safe>`
|
||
|
||
類似於 :ref:`call_thread_safe()<class_Node_method_call_thread_safe>`\ ,但用於設定屬性。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_set_translation_domain_inherited:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_translation_domain_inherited**\ (\ ) :ref:`🔗<class_Node_method_set_translation_domain_inherited>`
|
||
|
||
使本節點繼承其父節點的翻譯網域。若本節點沒有父節點,則會使用主要翻譯網域。
|
||
|
||
這是所有節點的預設行為。如呼叫 :ref:`Object.set_translation_domain()<class_Object_method_set_translation_domain>` 會停用此行為。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_update_configuration_warnings:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **update_configuration_warnings**\ (\ ) :ref:`🔗<class_Node_method_update_configuration_warnings>`
|
||
|
||
刷新在「場景」面板中為本節點顯示的警告。可用 :ref:`_get_configuration_warnings()<class_Node_private_method__get_configuration_warnings>` 自訂要顯示的警告訊息。
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)`
|
||
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
||
.. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)`
|
||
.. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)`
|
||
.. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)`
|
||
.. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)`
|
||
.. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)`
|
||
.. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)`
|
||
.. |void| replace:: :abbr:`void (無回傳值。)`
|