:github_url: hide .. _class_AnimationNodeBlendSpace2D: AnimationNodeBlendSpace2D ========================= **继承:** :ref:`AnimationRootNode` **<** :ref:`AnimationNode` **<** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` 一组放置在 2D 坐标上的 :ref:`AnimationRootNode`\ ,在三个相邻节点之间交叉淡化。被 :ref:`AnimationTree` 使用。 .. rst-class:: classref-introduction-group 描述 ---- :ref:`AnimationNodeBlendTree` 使用的资源。 \ **AnimationNodeBlendSpace2D** 代表放置 :ref:`AnimationRootNode` 的虚拟 2D 空间。输出的是使用 :ref:`Vector2` 权重对相邻的三个动画进行线性混合的结果。此处的“相邻”指的是构成包含当前值的三角形的三个 :ref:`AnimationRootNode`\ 。 你可以使用 :ref:`add_blend_point()` 向混合空间中添加顶点,将 :ref:`auto_triangles` 设为 ``true`` 可以将其自动三角形化。否则,请使用 :ref:`add_triangle()` 和 :ref:`remove_triangle()` 手动对混合空间进行三角形化。 .. rst-class:: classref-introduction-group 教程 ---- - :doc:`使用 AnimationTree <../tutorials/animation/animation_tree>` - `第三人称射击(TPS)演示 `__ .. rst-class:: classref-reftable-group 属性 ---- .. table:: :widths: auto +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`bool` | :ref:`auto_triangles` | ``true`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`BlendMode` | :ref:`blend_mode` | ``0`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`Vector2` | :ref:`max_space` | ``Vector2(1, 1)`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`Vector2` | :ref:`min_space` | ``Vector2(-1, -1)`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`Vector2` | :ref:`snap` | ``Vector2(0.1, 0.1)`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`bool` | :ref:`sync` | ``false`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`String` | :ref:`x_label` | ``"x"`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ | :ref:`String` | :ref:`y_label` | ``"y"`` | +------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+ .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_blend_point`\ (\ node\: :ref:`AnimationRootNode`, pos\: :ref:`Vector2`, at_index\: :ref:`int` = -1\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_triangle`\ (\ x\: :ref:`int`, y\: :ref:`int`, z\: :ref:`int`, at_index\: :ref:`int` = -1\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_blend_point_count`\ (\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`AnimationRootNode` | :ref:`get_blend_point_node`\ (\ point\: :ref:`int`\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_blend_point_position`\ (\ point\: :ref:`int`\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_triangle_count`\ (\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_triangle_point`\ (\ triangle\: :ref:`int`, point\: :ref:`int`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_blend_point`\ (\ point\: :ref:`int`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_triangle`\ (\ triangle\: :ref:`int`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_blend_point_node`\ (\ point\: :ref:`int`, node\: :ref:`AnimationRootNode`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_blend_point_position`\ (\ point\: :ref:`int`, pos\: :ref:`Vector2`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 信号 ---- .. _class_AnimationNodeBlendSpace2D_signal_triangles_updated: .. rst-class:: classref-signal **triangles_updated**\ (\ ) :ref:`🔗` 每当创建、移除混合空间的三角形,或当其中一个顶点改变位置时发出。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 枚举 ---- .. _enum_AnimationNodeBlendSpace2D_BlendMode: .. rst-class:: classref-enumeration enum **BlendMode**: :ref:`🔗` .. _class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_INTERPOLATED: .. rst-class:: classref-enumeration-constant :ref:`BlendMode` **BLEND_MODE_INTERPOLATED** = ``0`` 动画之间的插值是线性的。 .. _class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_DISCRETE: .. rst-class:: classref-enumeration-constant :ref:`BlendMode` **BLEND_MODE_DISCRETE** = ``1`` 混合空间播放混合位置最接近的动画节点的动画。可用于逐帧的 2D 动画。 .. _class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_DISCRETE_CARRY: .. rst-class:: classref-enumeration-constant :ref:`BlendMode` **BLEND_MODE_DISCRETE_CARRY** = ``2`` 类似于 :ref:`BLEND_MODE_DISCRETE`\ ,但在最后一个动画的播放位置开始新的动画。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 属性说明 -------- .. _class_AnimationNodeBlendSpace2D_property_auto_triangles: .. rst-class:: classref-property :ref:`bool` **auto_triangles** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_auto_triangles**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **get_auto_triangles**\ (\ ) 如果为 ``true``\ ,混合空间会自动进行三角测量。每次使用 :ref:`add_blend_point()` 和 :ref:`remove_blend_point()` 添加或移除点时,网格都会更新。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_blend_mode: .. rst-class:: classref-property :ref:`BlendMode` **blend_mode** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_blend_mode**\ (\ value\: :ref:`BlendMode`\ ) - :ref:`BlendMode` **get_blend_mode**\ (\ ) 控制动画之间的插值。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_max_space: .. rst-class:: classref-property :ref:`Vector2` **max_space** = ``Vector2(1, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_max_space**\ (\ value\: :ref:`Vector2`\ ) - :ref:`Vector2` **get_max_space**\ (\ ) 用于点的位置的混合空间的 X 轴和 Y 轴的上限。请参阅 :ref:`add_blend_point()`\ 。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_min_space: .. rst-class:: classref-property :ref:`Vector2` **min_space** = ``Vector2(-1, -1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_min_space**\ (\ value\: :ref:`Vector2`\ ) - :ref:`Vector2` **get_min_space**\ (\ ) 用于点的位置的混合空间的 X 轴和 Y 轴的下限。请参阅 :ref:`add_blend_point()`\ 。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_snap: .. rst-class:: classref-property :ref:`Vector2` **snap** = ``Vector2(0.1, 0.1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_snap**\ (\ value\: :ref:`Vector2`\ ) - :ref:`Vector2` **get_snap**\ (\ ) 移动点时要吸附到的位置增量。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_sync: .. rst-class:: classref-property :ref:`bool` **sync** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_use_sync**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_using_sync**\ (\ ) 如果为 ``false``\ ,则当混合值为 ``0`` 时,停止混合动画的帧。 如果为 ``true``\ ,则强制混合动画以前进帧。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_x_label: .. rst-class:: classref-property :ref:`String` **x_label** = ``"x"`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_x_label**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_x_label**\ (\ ) 混合空间 X 轴的名称。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_property_y_label: .. rst-class:: classref-property :ref:`String` **y_label** = ``"y"`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_y_label**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_y_label**\ (\ ) 混合空间 Y 轴的名称。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法说明 -------- .. _class_AnimationNodeBlendSpace2D_method_add_blend_point: .. rst-class:: classref-method |void| **add_blend_point**\ (\ node\: :ref:`AnimationRootNode`, pos\: :ref:`Vector2`, at_index\: :ref:`int` = -1\ ) :ref:`🔗` 在 ``pos`` 设定的位置添加一个代表 ``node`` 的新点。你可以使用 ``at_index`` 参数将其插入到特定的索引中。如果使用 ``at_index`` 的默认值,这个点会被插入到混合点数组的末尾。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_add_triangle: .. rst-class:: classref-method |void| **add_triangle**\ (\ x\: :ref:`int`, y\: :ref:`int`, z\: :ref:`int`, at_index\: :ref:`int` = -1\ ) :ref:`🔗` 使用三个点 ``x``\ 、\ ``y`` 和 ``z`` 创建一个新三角形。三角形可以重叠。可以使用 ``at_index`` 参数在特定索引处插入三角形。如果使用 ``at_index`` 的默认值,该点将插入到混合点数组的末尾。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_get_blend_point_count: .. rst-class:: classref-method :ref:`int` **get_blend_point_count**\ (\ ) |const| :ref:`🔗` 返回混合空间中的点的数量。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_get_blend_point_node: .. rst-class:: classref-method :ref:`AnimationRootNode` **get_blend_point_node**\ (\ point\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引 ``point`` 处的点所引用的 :ref:`AnimationRootNode`\ 。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_get_blend_point_position: .. rst-class:: classref-method :ref:`Vector2` **get_blend_point_position**\ (\ point\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引 ``point`` 处的点的位置。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_get_triangle_count: .. rst-class:: classref-method :ref:`int` **get_triangle_count**\ (\ ) |const| :ref:`🔗` 返回混合空间中三角形的数量。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_get_triangle_point: .. rst-class:: classref-method :ref:`int` **get_triangle_point**\ (\ triangle\: :ref:`int`, point\: :ref:`int`\ ) :ref:`🔗` 返回索引 ``point`` 处的点在索引 ``triangle`` 的三角形中的位置。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_remove_blend_point: .. rst-class:: classref-method |void| **remove_blend_point**\ (\ point\: :ref:`int`\ ) :ref:`🔗` 从混合空间中移除索引 ``point`` 处的点。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_remove_triangle: .. rst-class:: classref-method |void| **remove_triangle**\ (\ triangle\: :ref:`int`\ ) :ref:`🔗` 从混合空间中移除索引 ``triangle`` 处的三角形。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_set_blend_point_node: .. rst-class:: classref-method |void| **set_blend_point_node**\ (\ point\: :ref:`int`, node\: :ref:`AnimationRootNode`\ ) :ref:`🔗` 更改索引 ``point`` 处的点所引用的 :ref:`AnimationNode`\ 。 .. rst-class:: classref-item-separator ---- .. _class_AnimationNodeBlendSpace2D_method_set_blend_point_position: .. rst-class:: classref-method |void| **set_blend_point_position**\ (\ point\: :ref:`int`, pos\: :ref:`Vector2`\ ) :ref:`🔗` 更新混合空间中索引 ``point`` 处的点的位置。 .. |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 (无返回值。)`