mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
314 lines
16 KiB
ReStructuredText
314 lines
16 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback:
|
|
|
|
AnimationNodeStateMachinePlayback
|
|
=================================
|
|
|
|
**继承:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
|
|
为 :ref:`AnimationNodeStateMachine<class_AnimationNodeStateMachine>` 提供播放控制。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
描述
|
|
----
|
|
|
|
允许控制使用 :ref:`AnimationNodeStateMachine<class_AnimationNodeStateMachine>` 创建的 :ref:`AnimationTree<class_AnimationTree>` 状态机。使用 ``$AnimationTree.get("parameters/playback")`` 检索。
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
var state_machine = $AnimationTree.get("parameters/playback")
|
|
state_machine.travel("some_state")
|
|
|
|
.. code-tab:: csharp
|
|
|
|
var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback").As<AnimationNodeStateMachinePlayback>();
|
|
stateMachine.Travel("some_state");
|
|
|
|
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
教程
|
|
----
|
|
|
|
- :doc:`使用 AnimationTree <../tutorials/animation/animation_tree>`
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
属性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+-------------------------+-------------------------+---------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | resource_local_to_scene | ``true`` (overrides :ref:`Resource<class_Resource_property_resource_local_to_scene>`) |
|
|
+-------------------------+-------------------------+---------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
方法
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_current_length<class_AnimationNodeStateMachinePlayback_method_get_current_length>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`StringName<class_StringName>` | :ref:`get_current_node<class_AnimationNodeStateMachinePlayback_method_get_current_node>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_current_play_position<class_AnimationNodeStateMachinePlayback_method_get_current_play_position>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_fading_from_length<class_AnimationNodeStateMachinePlayback_method_get_fading_from_length>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`StringName<class_StringName>` | :ref:`get_fading_from_node<class_AnimationNodeStateMachinePlayback_method_get_fading_from_node>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_fading_from_play_position<class_AnimationNodeStateMachinePlayback_method_get_fading_from_play_position>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_fading_length<class_AnimationNodeStateMachinePlayback_method_get_fading_length>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_fading_position<class_AnimationNodeStateMachinePlayback_method_get_fading_position>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] | :ref:`get_travel_path<class_AnimationNodeStateMachinePlayback_method_get_travel_path>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimationNodeStateMachinePlayback_method_is_playing>`\ (\ ) |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`next<class_AnimationNodeStateMachinePlayback_method_next>`\ (\ ) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`start<class_AnimationNodeStateMachinePlayback_method_start>`\ (\ node\: :ref:`StringName<class_StringName>`, reset\: :ref:`bool<class_bool>` = true\ ) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`stop<class_AnimationNodeStateMachinePlayback_method_stop>`\ (\ ) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`travel<class_AnimationNodeStateMachinePlayback_method_travel>`\ (\ to_node\: :ref:`StringName<class_StringName>`, reset_on_teleport\: :ref:`bool<class_bool>` = true\ ) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
信号
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_signal_state_finished:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**state_finished**\ (\ state\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_AnimationNodeStateMachinePlayback_signal_state_finished>`
|
|
|
|
``state`` 播放完毕时发出。如果 ``state`` 是设置为编组模式的状态机,则其信号会以其名称作为前缀传递。
|
|
|
|
如果存在交叉淡入淡出,则它将在 :ref:`get_fading_from_node()<class_AnimationNodeStateMachinePlayback_method_get_fading_from_node>` 动画的影响不再存在时触发。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_signal_state_started:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**state_started**\ (\ state\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_AnimationNodeStateMachinePlayback_signal_state_started>`
|
|
|
|
当 ``state`` 开始播放时发出。如果 ``state`` 是一个设置为编组模式的状态机,则其信号将以其名称作为前缀传递。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
方法说明
|
|
--------
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_current_length:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_current_length**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_current_length>`
|
|
|
|
返回当前状态长度。
|
|
|
|
\ **注意:**\ 有可能任何 :ref:`AnimationRootNode<class_AnimationRootNode>` 既可以是节点也可以是动画。这意味着在单个状态中可以有多个动画。哪个动画长度会优先,取决于其内部连接的节点。此外,如果过渡未重置,则将返回该点的剩余长度。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_current_node:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`StringName<class_StringName>` **get_current_node**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_current_node>`
|
|
|
|
返回当前的动画播放状态。
|
|
|
|
\ **注意:**\ 使用交叉叠化时,当前状态会在交叉叠化开始后理解变为下一个状态。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_current_play_position:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_current_play_position**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_current_play_position>`
|
|
|
|
返回当前动画状态内的播放位置。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_fading_from_length:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_fading_from_length**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_fading_from_length>`
|
|
|
|
Returns the playback state length of the node from :ref:`get_fading_from_node()<class_AnimationNodeStateMachinePlayback_method_get_fading_from_node>`. Returns ``0`` if no animation fade is occurring.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_fading_from_node:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`StringName<class_StringName>` **get_fading_from_node**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_fading_from_node>`
|
|
|
|
返回当前淡入淡出动画的开始状态。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_fading_from_play_position:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_fading_from_play_position**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_fading_from_play_position>`
|
|
|
|
Returns the playback position of the node from :ref:`get_fading_from_node()<class_AnimationNodeStateMachinePlayback_method_get_fading_from_node>`. Returns ``0`` if no animation fade is occurring.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_fading_length:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_fading_length**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_fading_length>`
|
|
|
|
Returns the length of the current fade animation. Returns ``0`` if no animation fade is occurring.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_fading_position:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_fading_position**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_fading_position>`
|
|
|
|
Returns the playback position of the current fade animation. Returns ``0`` if no animation fade is occurring.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_get_travel_path:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] **get_travel_path**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_get_travel_path>`
|
|
|
|
返回 A\* 算法内部计算的当前行进路径。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_is_playing:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_playing**\ (\ ) |const| :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_is_playing>`
|
|
|
|
如果正在播放动画,返回 ``true``\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_next:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **next**\ (\ ) :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_next>`
|
|
|
|
如果通过行进或自动前进有下一条路径,则立即从当前状态过渡到下一个状态。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_start:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **start**\ (\ node\: :ref:`StringName<class_StringName>`, reset\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_start>`
|
|
|
|
开始播放给定的动画。
|
|
|
|
如果 ``reset`` 为 ``true``\ ,则动画从头开始播放。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_stop:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **stop**\ (\ ) :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_stop>`
|
|
|
|
停止当前播放的动画。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AnimationNodeStateMachinePlayback_method_travel:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **travel**\ (\ to_node\: :ref:`StringName<class_StringName>`, reset_on_teleport\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_AnimationNodeStateMachinePlayback_method_travel>`
|
|
|
|
按照最短的路径从当前状态过渡到另一个状态。
|
|
|
|
如果路径没有连接到当前状态,则动画将在状态传送后播放。
|
|
|
|
如果 ``reset_on_teleport`` 为 ``true``\ ,当行进导致传送时,该动画将从头开始播放。
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
|
|
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
|
|
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
|
|
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
|
|
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
|
|
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
|
|
.. |void| replace:: :abbr:`void (无返回值。)`
|