mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-05 14:10:19 +03:00
3066 lines
197 KiB
ReStructuredText
3066 lines
197 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. DO NOT EDIT THIS FILE!!!
|
||
.. Generated automatically from Godot engine sources.
|
||
.. Generator: https://github.com/godotengine/godot/tree/4.4/doc/tools/make_rst.py.
|
||
.. XML source: https://github.com/godotengine/godot/tree/4.4/doc/classes/Node.xml.
|
||
|
||
.. _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>` 函数可能更合适;当输入事件没有被其他节点(通常是 GUI :ref:`Control<class_Control>` 节点)处理时,才会调用这个函数,可以确保节点只接收到它该收到的事件。
|
||
|
||
为了记录场景的层次结构(尤其是在将场景实例化到其他场景时)可以用 :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>` 时传入方法名,将在本地和所有已连接的对等体中调用对应的方法(对等体=客户端和接受连接的服务器)。为了识别哪个节点收到 RPC 调用,Godot 将使用它的 :ref:`NodePath<class_NodePath>`\ (请确保所有对等体上的节点名称相同)。另外,请参阅高级网络教程和相应的演示。
|
||
|
||
\ **注意:**\ ``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_configuration_warnings<class_Node_private_method__get_configuration_warnings>`\ (\ ) |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_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:`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:`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:`Variant<class_Variant>` | :ref:`get_rpc_config<class_Node_method_get_rpc_config>`\ (\ ) |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_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``
|
||
|
||
复制该节点的信号连接。
|
||
|
||
.. _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>` 作为该节点及其子节点副本的基础。
|
||
|
||
.. 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``
|
||
|
||
始终不自动翻译。和 :ref:`AUTO_TRANSLATE_MODE_ALWAYS<class_Node_constant_AUTO_TRANSLATE_MODE_ALWAYS>` 相反。
|
||
|
||
生成 POT 解析字符串时会跳过该节点,如果子节点为 :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>`
|
||
|
||
当节点即将退出 :ref:`SceneTree<class_SceneTree>` 时收到的通知。请参阅 :ref:`_exit_tree()<class_Node_private_method__exit_tree>`\ 。
|
||
|
||
该通知会在相关的 :ref:`tree_exiting<class_Node_signal_tree_exiting>` 信号\ *之后*\ 收到。
|
||
|
||
.. _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:`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>`
|
||
|
||
鼠标进入窗口时收到的通知。
|
||
|
||
为内嵌窗口实现,并在桌面和 Web 平台上实现。
|
||
|
||
.. _class_Node_constant_NOTIFICATION_WM_MOUSE_EXIT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_WM_MOUSE_EXIT** = ``1003`` :ref:`🔗<class_Node_constant_NOTIFICATION_WM_MOUSE_EXIT>`
|
||
|
||
鼠标离开窗口时收到的通知。
|
||
|
||
为内嵌窗口实现,并在桌面和 Web 平台上实现。
|
||
|
||
.. _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>`
|
||
|
||
当输入法引擎发生更新时,从操作系统收到的通知(例如,IME 光标位置或组成字符串的变化)。
|
||
|
||
仅在 macOS 上被实现。
|
||
|
||
.. _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>` 被更改时收到的通知。
|
||
|
||
.. 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**\ (\ )
|
||
|
||
定义是否应该根据当前区域设置自动将所有文本更改为翻译后的版本(针对 :ref:`Label<class_Label>`\ 、\ :ref:`RichTextLabel<class_RichTextLabel>`\ 、\ :ref:`Window<class_Window>` 等节点)。同时也会决定生成 POT 时是否解析该节点的字符串。
|
||
|
||
\ **注意:**\ 根节点的自动翻译模式也可以通过 :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>` 后设置所有者。
|
||
|
||
.. 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**\ (\ )
|
||
|
||
允许启用或禁用每个节点的物理插值,提供比全局打开和关闭物理插值更精细的控制。请参阅 :ref:`ProjectSettings.physics/common/physics_interpolation<class_ProjectSettings_property_physics/common/physics_interpolation>` 和 :ref:`SceneTree.physics_interpolation<class_SceneTree_property_physics_interpolation>` 了解全局设置。
|
||
|
||
\ **注意:**\ 将节点传送到远处时,应使用 :ref:`reset_physics_interpolation()<class_Node_method_reset_physics_interpolation>` 暂时禁用插值。
|
||
|
||
.. 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**\ (\ )
|
||
|
||
该节点的处理行为(请参阅 :ref:`ProcessMode<enum_Node_ProcessMode>`\ )。要检查该节点是否能够在当前模式下进行处理,请使用 :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:`_physics_process()<class_Node_private_method__physics_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>` 的另一个节点与该节点共享相同的 :ref:`name<class_Node_property_name>`\ ,则另一个节点将不可再作为唯一节点名称进行访问。
|
||
|
||
.. 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_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__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>`
|
||
|
||
在主循环的物理处理步骤中调用。物理处理的帧率与物理同步,即 ``delta`` 参数\ *通常*\ 不变(例外见下文)。\ ``delta`` 的单位为秒。
|
||
|
||
启用物理处理后才会调用该方法,覆盖该方法后会自动启用,可以使用 :ref:`set_physics_process()<class_Node_method_set_physics_process>` 开关。
|
||
|
||
处理按照 :ref:`process_physics_priority<class_Node_property_process_physics_priority>` 的顺序进行,优先级取值越低越先调用。优先级相同的节点按照树顺序处理,即编辑器中从上到下的顺序(也叫前序遍历)。
|
||
|
||
对应 :ref:`Object._notification()<class_Object_private_method__notification>` 中的 :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 时 ``delta`` 会比正常情况大。这样做是为了避免产生“死亡螺旋”。在这种情况下,由于每帧物理步骤数量的不断增加,性能会急剧下降。\ :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_private_method__process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_process**\ (\ delta\: :ref:`float<class_float>`\ ) |virtual| :ref:`🔗<class_Node_private_method__process>`
|
||
|
||
在主循环的处理步骤中调用。每一帧都会尽快进行处理,因此表示自上一帧以来时间增量的 ``delta`` 会发生变化。\ ``delta`` 的单位为秒。
|
||
|
||
启用处理后才会调用该方法,覆盖该方法后会自动启用,可以使用 :ref:`set_process()<class_Node_method_set_process>` 开关。
|
||
|
||
处理按照 :ref:`process_priority<class_Node_property_process_priority>` 的顺序进行,优先级取值越低越先调用。优先级相同的节点按照树顺序处理,即编辑器中从上到下的顺序(也叫前序遍历)。
|
||
|
||
对应 :ref:`Object._notification()<class_Object_private_method__notification>` 中的 :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 时 ``delta`` 会比正常情况大。这样做是为了避免产生“死亡螺旋”。在这种情况下,由于每帧物理步骤数量的不断增加,性能会急剧下降。\ :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_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>` 等无关事件会被自动过滤。
|
||
|
||
\ **注意:**\ 只有当节点存在于场景树中(即不是孤立节点)时,该方法才会被调用。
|
||
|
||
.. 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>`
|
||
|
||
将 ``node`` 添加为子节点。节点可以有任意数量的子节点,但子节点的名称必须唯一。删除父节点时会自动删除子节点,因此可以通过删除最顶层的节点来删除整个场景。
|
||
|
||
如果 ``force_readable_name`` 为 ``true``\ ,则将提高所添加的 ``node`` 的可读性。如果尚未命名,\ ``node`` 将重命名为它的类型,如果存在 :ref:`name<class_Node_property_name>` 相同的同级节点,则会添加合适的数字后缀。这个操作很慢。因此,建议将其保留为 ``false``\ ,在这两种情况下会分配包含 ``@`` 的虚设名称。
|
||
|
||
如果 ``internal`` 不同于 :ref:`INTERNAL_MODE_DISABLED<class_Node_constant_INTERNAL_MODE_DISABLED>`\ ,则该子节点将被添加为内部节点。\ :ref:`get_children()<class_Node_method_get_children>` 等方法会忽略这些节点,除非它们的参数 ``include_internal`` 为 ``true``\ 。这种功能的设计初衷是对用户隐藏内部节点,这样用户就不会意外删除或修改这些节点。部分 GUI 节点会使用这个功能,例如 :ref:`ColorPicker<class_ColorPicker>`\ 。可用的模式见 :ref:`InternalMode<enum_Node_InternalMode>`\ 。
|
||
|
||
\ **注意:**\ 如果 ``node`` 已经有父节点,则该方法会失败。请先使用 :ref:`remove_child()<class_Node_method_remove_child>` 将 ``node`` 从其当前父节点中移除。例如:
|
||
|
||
|
||
.. 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);
|
||
|
||
|
||
|
||
如果你需要将子节点添加到子节点列表中特定节点的下方,请使用 :ref:`add_sibling()<class_Node_method_add_sibling>` 而不是该方法。
|
||
|
||
\ **注意:**\ 如果想让子节点持久化到某个 :ref:`PackedScene<class_PackedScene>` 的,除了调用 :ref:`add_child()<class_Node_method_add_child>` 之外,还必须设置 :ref:`owner<class_Node_property_owner>`\ 。通常在\ :doc:`工具脚本 <../tutorials/plugins/running_code_in_the_editor>`\ 和\ :doc:`编辑器插件 <../tutorials/plugins/editor/index>`\ 中会用到。如果在没有设置 :ref:`owner<class_Node_property_owner>`\ ,只调用了 :ref:`add_child()<class_Node_method_add_child>`\ ,则新添加的 **Node** 在场景树中将不可见,但在 2D/3D 视图中却是可见的。
|
||
|
||
.. 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>`
|
||
|
||
将该节点加入 ``group`` 分组。使用分组可以很方便地组织部分节点,例如将敌人加入 ``"enemies"`` 分组、将收集品加入 ``"collectables"`` 分组。注意事项见下文,以及 :ref:`SceneTree<class_SceneTree>` 中相关的分组方法。
|
||
|
||
如果 ``persistent`` 为 ``true``\ ,则保存 :ref:`PackedScene<class_PackedScene>` 时会存储该分组。在“节点”面板中创建、显示的分组都能够进行持久化。
|
||
|
||
\ **注意:**\ 为了提升性能,\ *并不*\ 保证分组名称的顺序,每次运行项目可能会不同。因此请不要依赖分组的顺序。
|
||
|
||
\ **注意:**\ 不再场景树中时,\ :ref:`SceneTree<class_SceneTree>` 的分组方法\ *无法*\ 正常工作(见 :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_process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **can_process**\ (\ ) |const| :ref:`🔗<class_Node_method_can_process>`
|
||
|
||
如果节点可以接收 :ref:`SceneTree<class_SceneTree>` 和 :ref:`Viewport<class_Viewport>` 的处理通知和输入回调(\ :ref:`NOTIFICATION_PROCESS<class_Node_constant_NOTIFICATION_PROCESS>`\ 、\ :ref:`_input()<class_Node_private_method__input>` 等)则返回 ``true``\ 。返回值取决于 :ref:`process_mode<class_Node_property_process_mode>`\ :
|
||
|
||
- 如果设为 :ref:`PROCESS_MODE_PAUSABLE<class_Node_constant_PROCESS_MODE_PAUSABLE>`\ ,则会在游戏处理时返回 ``true``\ ,即 :ref:`SceneTree.paused<class_SceneTree_property_paused>` 为 ``false`` 的情况;
|
||
|
||
- 如果设为 :ref:`PROCESS_MODE_WHEN_PAUSED<class_Node_constant_PROCESS_MODE_WHEN_PAUSED>`\ ,则会在游戏暂停时返回 ``true``\ ,即 :ref:`SceneTree.paused<class_SceneTree_property_paused>` 为 ``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>`\ )。有关绑定到节点的 Tween 的更多信息,请参阅 :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>`
|
||
|
||
复制该节点,返回一个新节点,其中包含从原始节点复制的所有属性、信号、组、子节点。可以通过 ``flags`` 调整该行为(见 :ref:`DuplicateFlags<enum_Node_DuplicateFlags>`\ )。
|
||
|
||
\ **注意:**\ 对于附带有 :ref:`Script<class_Script>` 的节点,如果 :ref:`Object._init()<class_Object_private_method__init>` 已使用所需参数定义,则复制的节点将不会有 :ref:`Script<class_Script>`\ 。
|
||
|
||
.. 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:`Array<class_Array>`\ 。匹配是通过 :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_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>`
|
||
|
||
通过索引获取子节点。每个子节点都有一个相对于其同级节点的索引(请参阅 :ref:`get_index()<class_Node_method_get_index>`\ )。第一个子节点位于索引 0 处。负值也可用于从列表末尾开始。该方法可以与 :ref:`get_child_count()<class_Node_method_get_child_count>` 结合使用来迭代该节点的子节点。如果给定索引处不存在子节点,则该方法返回 ``null`` 并生成一个错误。
|
||
|
||
如果 ``include_internal`` 为 ``false``\ ,则忽略内部子节点(请参阅 :ref:`add_child()<class_Node_method_add_child>` 的 ``internal`` 参数)。
|
||
|
||
::
|
||
|
||
# 假设以下是该节点的子节点(按顺序):
|
||
# 第一、中间、最后。
|
||
|
||
var a = get_child(0).name # a 是 “第一”
|
||
var b = get_child(1).name # b 是 “中间”
|
||
var b = get_child(2).name # b 是 “最后”
|
||
var c = get_child(-1).name # c 是 “最后”
|
||
|
||
\ **注意:**\ 要通过 :ref:`NodePath<class_NodePath>` 获取节点,请使用 :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>`
|
||
|
||
获取节点及其由 :ref:`NodePath<class_NodePath>` 子名指定的嵌套最深的资源。返回一个大小为 ``3`` 的 :ref:`Array<class_Array>`\ ,其中:
|
||
|
||
- 元素 ``0`` 是 **Node**\ ,如果找不到,则为 ``null``\ ;
|
||
|
||
- 元素 ``1`` 是子名中最后嵌套的 :ref:`Resource<class_Resource>`\ ,如果找不到,则为 ``null``\ ;
|
||
|
||
- 元素 ``2`` 是剩余的 :ref:`NodePath<class_NodePath>`\ ,引用一个已有的非 :ref:`Resource<class_Resource>` 属性(请参阅 :ref:`Object.get_indexed()<class_Object_method_get_indexed>`\ )。
|
||
|
||
\ **示例:**\ 假设子节点的 :ref:`Sprite2D.texture<class_Sprite2D_property_texture>` 已被分配了一个\ :ref:`AtlasTexture<class_AtlasTexture>`\ :
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
var a = get_node_and_resource("Area2D/Sprite2D")
|
||
print(a[0].name) # 打印 Sprite2D
|
||
print(a[1]) # 打印 <null>
|
||
print(a[2]) # 打印 ^""
|
||
|
||
var b = get_node_and_resource("Area2D/Sprite2D:texture:atlas")
|
||
print(b[0].name) # 打印 Sprite2D
|
||
print(b[1].get_class()) # 打印 AtlasTexture
|
||
print(b[2]) # 打印 ^""
|
||
|
||
var c = get_node_and_resource("Area2D/Sprite2D:texture:atlas:region")
|
||
print(c[0].name) # 打印 Sprite2D
|
||
print(c[1].get_class()) # 打印 AtlasTexture
|
||
print(c[2]) # 打印 ^":region"
|
||
|
||
.. code-tab:: csharp
|
||
|
||
var a = GetNodeAndResource(NodePath("Area2D/Sprite2D"));
|
||
GD.Print(a[0].Name); // 打印 Sprite2D
|
||
GD.Print(a[1]); // 打印 <null>
|
||
GD.Print(a[2]); // 打印 ^"
|
||
|
||
var b = GetNodeAndResource(NodePath("Area2D/Sprite2D:texture:atlas"));
|
||
GD.Print(b[0].name); // 打印 Sprite2D
|
||
GD.Print(b[1].get_class()); // 打印 AtlasTexture
|
||
GD.Print(b[2]); // 打印 ^""
|
||
|
||
var c = GetNodeAndResource(NodePath("Area2D/Sprite2D:texture:atlas:region"));
|
||
GD.Print(c[0].name); // 打印 Sprite2D
|
||
GD.Print(c[1].get_class()); // 打印 AtlasTexture
|
||
GD.Print(c[2]); // 打印 ^":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_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_rpc_config:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Variant<class_Variant>` **get_rpc_config**\ (\ ) |const| :ref:`🔗<class_Node_method_get_rpc_config>`
|
||
|
||
返回一个 :ref:`Dictionary<class_Dictionary>`\ ,将方法名称映射到针对该节点使用 :ref:`rpc_config()<class_Node_method_rpc_config>` 为其定义的 RPC 配置。
|
||
|
||
.. 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:`String<class_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>`\ ,会将树以 :ref:`String<class_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>`
|
||
|
||
如果该节点启用了物理插值,则返回 ``true``\ (请参阅 :ref:`physics_interpolation_mode<class_Node_property_physics_interpolation_mode>`\ )。
|
||
|
||
\ **注意:**\ 仅当同时设置了标志\ **并且**\ 在 :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>`
|
||
|
||
输出所有孤立节点(\ :ref:`SceneTree<class_SceneTree>` 之外的节点)。利于调试。
|
||
|
||
\ **注意:**\ 该方法仅适用于调试构建版本。在以发布模式导出的项目中不执行任何操作。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Node_method_print_tree:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **print_tree**\ (\ ) :ref:`🔗<class_Node_method_print_tree>`
|
||
|
||
将该节点及其子节点打印到标准输出,会进行递归操作。该节点可以不在树中。这个方法输出的是相对于当前节点的路径,适合复制/粘贴到 :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>`
|
||
|
||
在该节点上并递归地在其所有子节点上,使用 ``what`` 调用 :ref:`Object.notification()<class_Object_method_notification>`\ 。
|
||
|
||
.. 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>` 不同,该节点不会被立即删除,并且它在被删除前仍然可以访问。多次调用 :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``\ 。该 ``node`` 及其子节点\ **不会**\ 被删除。要删除节点,见 :ref:`queue_free()<class_Node_method_queue_free>`\ 。
|
||
|
||
\ **注意:**\ 当该节点位于场景树中时,如果被移除的 ``node``\ (或其后代)的 :ref:`owner<class_Node_property_owner>` 不再是祖先(参见 :ref:`is_ancestor_of()<class_Node_method_is_ancestor_of>`\ ),则该方法将它们的 :ref:`owner<class_Node_property_owner>` 设置为 ``null``\ 。
|
||
|
||
.. 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`` 中移除该节点。如果该节点不在 ``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>`\ 。
|
||
|
||
\ **注意:**\ 该方法只影响当前节点。如果该节点的子节点也需要请求就绪,则需要为每个子节点调用该方法。当节点及其子节点再次进入树时,\ :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>`\ 。行为取决于给定 ``method`` 的 RPC 配置(请参阅 :ref:`rpc_config()<class_Node_method_rpc_config>` 和 :ref:`@GDScript.@rpc<class_@GDScript_annotation_@rpc>`\ )。默认情况下,方法不会暴露给 RPC。
|
||
|
||
如果调用成功,则返回 :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>`\ ;如果 ``method`` 中传递的参数不匹配,则返回 :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:`multiplayer<class_Node_property_multiplayer>` 的连接不可用,则返回 :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``\ :一个 :ref:`int<class_int>` 表示启用了发送 RPC 的通道。
|
||
|
||
\ **注意:**\ 在 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>`\ ;如果 ``method`` 中传递的参数不匹配,则返回 :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:`multiplayer<class_Node_property_multiplayer>` 的连接不可用,则返回 :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>`
|
||
|
||
将该节点的多人游戏控制方设置为具有给定对等体 ``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>` 被调用之前自动启用。对于 GUI 控件,例如 :ref:`Button<class_Button>` 和 :ref:`TextEdit<class_TextEdit>`\ ,则未处理的输入处理也早已启用。
|
||
|
||
.. 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>`
|
||
|
||
如果设置为 ``true``\ ,则当从 :ref:`PackedScene<class_PackedScene>` 打包和实例化时,节点将变为 :ref:`InstancePlaceholder<class_InstancePlaceholder>`\ 。另见 :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 (本方法通常需要用户覆盖才能生效。)`
|
||
.. |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 (无返回值。)`
|