Files
godot-docs-l10n/classes/zh_CN/class_polygon2d.rst

479 lines
23 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Polygon2D.xml.
.. _class_Polygon2D:
Polygon2D
=========
**继承:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
2D 多边形。
.. rst-class:: classref-introduction-group
描述
----
Polygon2D 由一组点定义。每个点都连接到下一个点最后一个点连接到第一个点从而形成一个封闭的多边形。Polygon2D 可以填充颜色(纯色或渐变),也可以填充给定的纹理。
.. rst-class:: classref-reftable-group
属性
----
.. table::
:widths: auto
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`antialiased<class_Polygon2D_property_antialiased>` | ``false`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Array<class_Array>` | :ref:`bones<class_Polygon2D_property_bones>` | ``[]`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Color<class_Color>` | :ref:`color<class_Polygon2D_property_color>` | ``Color(1, 1, 1, 1)`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`int<class_int>` | :ref:`internal_vertex_count<class_Polygon2D_property_internal_vertex_count>` | ``0`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`float<class_float>` | :ref:`invert_border<class_Polygon2D_property_invert_border>` | ``100.0`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`invert_enabled<class_Polygon2D_property_invert_enabled>` | ``false`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`offset<class_Polygon2D_property_offset>` | ``Vector2(0, 0)`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`polygon<class_Polygon2D_property_polygon>` | ``PackedVector2Array()`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Array<class_Array>` | :ref:`polygons<class_Polygon2D_property_polygons>` | ``[]`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`NodePath<class_NodePath>` | :ref:`skeleton<class_Polygon2D_property_skeleton>` | ``NodePath("")`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_Polygon2D_property_texture>` | |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`texture_offset<class_Polygon2D_property_texture_offset>` | ``Vector2(0, 0)`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`float<class_float>` | :ref:`texture_rotation<class_Polygon2D_property_texture_rotation>` | ``0.0`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`texture_scale<class_Polygon2D_property_texture_scale>` | ``Vector2(1, 1)`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`uv<class_Polygon2D_property_uv>` | ``PackedVector2Array()`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
| :ref:`PackedColorArray<class_PackedColorArray>` | :ref:`vertex_colors<class_Polygon2D_property_vertex_colors>` | ``PackedColorArray()`` |
+-----------------------------------------------------+------------------------------------------------------------------------------+--------------------------+
.. rst-class:: classref-reftable-group
方法
----
.. table::
:widths: auto
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_bone<class_Polygon2D_method_add_bone>`\ (\ path\: :ref:`NodePath<class_NodePath>`, weights\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`clear_bones<class_Polygon2D_method_clear_bones>`\ (\ ) |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`erase_bone<class_Polygon2D_method_erase_bone>`\ (\ index\: :ref:`int<class_int>`\ ) |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_bone_count<class_Polygon2D_method_get_bone_count>`\ (\ ) |const| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`NodePath<class_NodePath>` | :ref:`get_bone_path<class_Polygon2D_method_get_bone_path>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`get_bone_weights<class_Polygon2D_method_get_bone_weights>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_bone_path<class_Polygon2D_method_set_bone_path>`\ (\ index\: :ref:`int<class_int>`, path\: :ref:`NodePath<class_NodePath>`\ ) |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_bone_weights<class_Polygon2D_method_set_bone_weights>`\ (\ index\: :ref:`int<class_int>`, weights\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
属性说明
--------
.. _class_Polygon2D_property_antialiased:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **antialiased** = ``false`` :ref:`🔗<class_Polygon2D_property_antialiased>`
.. rst-class:: classref-property-setget
- |void| **set_antialiased**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_antialiased**\ (\ )
如果为 ``true``\ ,则多边形边缘将进行抗锯齿。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_bones:
.. rst-class:: classref-property
:ref:`Array<class_Array>` **bones** = ``[]`` :ref:`🔗<class_Polygon2D_property_bones>`
分配的 :ref:`skeleton<class_Polygon2D_property_skeleton>` 所使用的 :ref:`Bone2D<class_Bone2D>` 节点的内部列表。使用 Polygon2D 编辑器编辑顶部工具栏的“UV”按钮
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_color:
.. rst-class:: classref-property
:ref:`Color<class_Color>` **color** = ``Color(1, 1, 1, 1)`` :ref:`🔗<class_Polygon2D_property_color>`
.. rst-class:: classref-property-setget
- |void| **set_color**\ (\ value\: :ref:`Color<class_Color>`\ )
- :ref:`Color<class_Color>` **get_color**\ (\ )
该多边形的填充颜色。如果设置了 :ref:`texture<class_Polygon2D_property_texture>`\ ,它将乘以该颜色。它也将是未在 :ref:`vertex_colors<class_Polygon2D_property_vertex_colors>` 中设置的顶点的默认颜色。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_internal_vertex_count:
.. rst-class:: classref-property
:ref:`int<class_int>` **internal_vertex_count** = ``0`` :ref:`🔗<class_Polygon2D_property_internal_vertex_count>`
.. rst-class:: classref-property-setget
- |void| **set_internal_vertex_count**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_internal_vertex_count**\ (\ )
内部顶点的数量,用于 UV 映射。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_invert_border:
.. rst-class:: classref-property
:ref:`float<class_float>` **invert_border** = ``100.0`` :ref:`🔗<class_Polygon2D_property_invert_border>`
.. rst-class:: classref-property-setget
- |void| **set_invert_border**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_invert_border**\ (\ )
添加了当 :ref:`invert_enabled<class_Polygon2D_property_invert_enabled>` 被设置为 ``true`` 时应用于边界框的填充。将该值设置得太小可能会产生一个“Bad Polygon”错误。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_invert_enabled:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **invert_enabled** = ``false`` :ref:`🔗<class_Polygon2D_property_invert_enabled>`
.. rst-class:: classref-property-setget
- |void| **set_invert_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_invert_enabled**\ (\ )
如果为 ``true``\ ,则多边形将被反转,包含定义点之外的区域并延伸到 :ref:`invert_border<class_Polygon2D_property_invert_border>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_offset:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Polygon2D_property_offset>`
.. rst-class:: classref-property-setget
- |void| **set_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_offset**\ (\ )
应用于每个顶点的位置偏移量。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_polygon:
.. rst-class:: classref-property
:ref:`PackedVector2Array<class_PackedVector2Array>` **polygon** = ``PackedVector2Array()`` :ref:`🔗<class_Polygon2D_property_polygon>`
.. rst-class:: classref-property-setget
- |void| **set_polygon**\ (\ value\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ )
- :ref:`PackedVector2Array<class_PackedVector2Array>` **get_polygon**\ (\ )
多边形的顶点列表。最后一点将连接到第一个点。
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedVector2Array<class_PackedVector2Array>` for more details.
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_polygons:
.. rst-class:: classref-property
:ref:`Array<class_Array>` **polygons** = ``[]`` :ref:`🔗<class_Polygon2D_property_polygons>`
.. rst-class:: classref-property-setget
- |void| **set_polygons**\ (\ value\: :ref:`Array<class_Array>`\ )
- :ref:`Array<class_Array>` **get_polygons**\ (\ )
多边形数量大于一时的多边形列表。每个独立的多边形都作为 :ref:`PackedInt32Array<class_PackedInt32Array>` 存储,其中的每个 :ref:`int<class_int>` 都是对 :ref:`polygon<class_Polygon2D_property_polygon>` 某个点的索引。如果为空,则会忽略这个属性,得到由 :ref:`polygon<class_Polygon2D_property_polygon>` 中所有点构成的单个多边形,顺序与存储顺序一致。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_skeleton:
.. rst-class:: classref-property
:ref:`NodePath<class_NodePath>` **skeleton** = ``NodePath("")`` :ref:`🔗<class_Polygon2D_property_skeleton>`
.. rst-class:: classref-property-setget
- |void| **set_skeleton**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
- :ref:`NodePath<class_NodePath>` **get_skeleton**\ (\ )
指向 :ref:`Skeleton2D<class_Skeleton2D>` 节点的路径,用于对这个多边形进行基于骨架的变形。如果为空或无效,则不会使用骨架变形。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_texture:
.. rst-class:: classref-property
:ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_Polygon2D_property_texture>`
.. rst-class:: classref-property-setget
- |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
- :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
该多边形的填充纹理。使用 :ref:`uv<class_Polygon2D_property_uv>` 设置纹理坐标。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_texture_offset:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **texture_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Polygon2D_property_texture_offset>`
.. rst-class:: classref-property-setget
- |void| **set_texture_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_texture_offset**\ (\ )
多边形的 :ref:`texture<class_Polygon2D_property_texture>` 纹理的偏移量。如果设置为 ``Vector2(0, 0)``\ ,则纹理的原点(其左上角)将放置在该多边形的位置。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_texture_rotation:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_rotation** = ``0.0`` :ref:`🔗<class_Polygon2D_property_texture_rotation>`
.. rst-class:: classref-property-setget
- |void| **set_texture_rotation**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_rotation**\ (\ )
纹理的旋转弧度。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_texture_scale:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **texture_scale** = ``Vector2(1, 1)`` :ref:`🔗<class_Polygon2D_property_texture_scale>`
.. rst-class:: classref-property-setget
- |void| **set_texture_scale**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_texture_scale**\ (\ )
使用 :ref:`texture<class_Polygon2D_property_texture>` 时乘以 :ref:`uv<class_Polygon2D_property_uv>` 坐标的量。值越大,纹理越小,反之亦然。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_uv:
.. rst-class:: classref-property
:ref:`PackedVector2Array<class_PackedVector2Array>` **uv** = ``PackedVector2Array()`` :ref:`🔗<class_Polygon2D_property_uv>`
.. rst-class:: classref-property-setget
- |void| **set_uv**\ (\ value\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ )
- :ref:`PackedVector2Array<class_PackedVector2Array>` **get_uv**\ (\ )
多边形每个顶点的纹理坐标。每个多边形顶点应该有一个 UV 值。如果数量少,则未定义的顶点将使用 ``Vector2(0, 0)``\ 。
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedVector2Array<class_PackedVector2Array>` for more details.
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_property_vertex_colors:
.. rst-class:: classref-property
:ref:`PackedColorArray<class_PackedColorArray>` **vertex_colors** = ``PackedColorArray()`` :ref:`🔗<class_Polygon2D_property_vertex_colors>`
.. rst-class:: classref-property-setget
- |void| **set_vertex_colors**\ (\ value\: :ref:`PackedColorArray<class_PackedColorArray>`\ )
- :ref:`PackedColorArray<class_PackedColorArray>` **get_vertex_colors**\ (\ )
每个顶点的颜色。颜色在顶点之间插值,从而产生平滑的渐变。每个多边形顶点应该有一个。如果数量较少,则未定义的顶点将使用 :ref:`color<class_Polygon2D_property_color>`\ 。
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedColorArray<class_PackedColorArray>` for more details.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _class_Polygon2D_method_add_bone:
.. rst-class:: classref-method
|void| **add_bone**\ (\ path\: :ref:`NodePath<class_NodePath>`, weights\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) :ref:`🔗<class_Polygon2D_method_add_bone>`
添加指定 ``path````weights`` 的骨骼。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_clear_bones:
.. rst-class:: classref-method
|void| **clear_bones**\ (\ ) :ref:`🔗<class_Polygon2D_method_clear_bones>`
删除这个 **Polygon2D** 的所有骨骼。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_erase_bone:
.. rst-class:: classref-method
|void| **erase_bone**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Polygon2D_method_erase_bone>`
从这个 **Polygon2D** 中删除指定的骨骼。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_get_bone_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_bone_count**\ (\ ) |const| :ref:`🔗<class_Polygon2D_method_get_bone_count>`
返回这个 **Polygon2D** 中骨骼的数量。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_get_bone_path:
.. rst-class:: classref-method
:ref:`NodePath<class_NodePath>` **get_bone_path**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Polygon2D_method_get_bone_path>`
返回与指定骨骼相关联的节点的路径。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_get_bone_weights:
.. rst-class:: classref-method
:ref:`PackedFloat32Array<class_PackedFloat32Array>` **get_bone_weights**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Polygon2D_method_get_bone_weights>`
返回指定骨骼的权重值。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_set_bone_path:
.. rst-class:: classref-method
|void| **set_bone_path**\ (\ index\: :ref:`int<class_int>`, path\: :ref:`NodePath<class_NodePath>`\ ) :ref:`🔗<class_Polygon2D_method_set_bone_path>`
设置与指定骨骼相关联的节点的路径。
.. rst-class:: classref-item-separator
----
.. _class_Polygon2D_method_set_bone_weights:
.. rst-class:: classref-method
|void| **set_bone_weights**\ (\ index\: :ref:`int<class_int>`, weights\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) :ref:`🔗<class_Polygon2D_method_set_bone_weights>`
设置指定骨骼的权重值。
.. |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 (无返回值。)`