Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Polygon2D
繼承: Node2D < CanvasItem < Node < Object
2D 多邊形。
說明
Polygon2D 由一組點定義。每個點都連接到下一個點,最後一個點連接到第一個點,從而形成一個封閉的多邊形。Polygon2D 可以填充顏色(純色或漸變),也可以填充給定的紋理。
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
add_bone(path: NodePath, weights: PackedFloat32Array) |
void |
|
void |
erase_bone(index: int) |
get_bone_count() const |
|
get_bone_path(index: int) const |
|
get_bone_weights(index: int) const |
|
void |
set_bone_path(index: int, path: NodePath) |
void |
set_bone_weights(index: int, weights: PackedFloat32Array) |
屬性說明
如果為 true,則多邊形邊緣將進行抗鋸齒。
Color color = Color(1, 1, 1, 1) 🔗
The polygon's fill color. If texture is set, it will be multiplied by this color. It will also be the default color for vertices not set in vertex_colors.
int internal_vertex_count = 0 🔗
內部頂點的數量,用於 UV 對應。
新增了當 invert_enabled 被設定為 true 時套用於邊界框的填充。將該值設定得太小可能會產生一個“Bad Polygon”錯誤。
如果為 true,則多邊形將被反轉,包含定義點之外的區域並延伸到 invert_border。
Vector2 offset = Vector2(0, 0) 🔗
套用於每個頂點的位置偏移量。
PackedVector2Array polygon = PackedVector2Array() 🔗
void set_polygon(value: PackedVector2Array)
PackedVector2Array get_polygon()
The polygon's list of vertices. The final point will be connected to the first.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.
多邊形數量大於一時的多邊形列表。每個獨立的多邊形都作為 PackedInt32Array 存儲,其中的每個 int 都是對 polygon 某個點的索引。如果為空,則會忽略這個屬性,得到由 polygon 中所有點構成的單個多邊形,順序與儲存順序一致。
NodePath skeleton = NodePath("") 🔗
指向 Skeleton2D 節點的路徑,用於對這個多邊形進行基於骨架的變形。如果為空或無效,則不會使用骨架變形。
The polygon's fill texture. Use uv to set texture coordinates.
Vector2 texture_offset = Vector2(0, 0) 🔗
Amount to offset the polygon's texture. If set to Vector2(0, 0), the texture's origin (its top-left corner) will be placed at the polygon's position.
float texture_rotation = 0.0 🔗
紋理的旋轉弧度。
Vector2 texture_scale = Vector2(1, 1) 🔗
Amount to multiply the uv coordinates when using texture. Larger values make the texture smaller, and vice versa.
PackedVector2Array uv = PackedVector2Array() 🔗
void set_uv(value: PackedVector2Array)
PackedVector2Array get_uv()
Texture coordinates for each vertex of the polygon. There should be one UV value per polygon vertex. If there are fewer, undefined vertices will use Vector2(0, 0).
Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.
PackedColorArray vertex_colors = PackedColorArray() 🔗
void set_vertex_colors(value: PackedColorArray)
PackedColorArray get_vertex_colors()
Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use color.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedColorArray for more details.
方法說明
void add_bone(path: NodePath, weights: PackedFloat32Array) 🔗
新增指定 path 和 weights 的骨骼。
void clear_bones() 🔗
刪除這個 Polygon2D 的所有骨骼。
從這個 Polygon2D 中刪除指定的骨骼。
返回這個 Polygon2D 中骨骼的數量。
NodePath get_bone_path(index: int) const 🔗
返回與指定骨骼相關聯的節點的路徑。
PackedFloat32Array get_bone_weights(index: int) const 🔗
返回指定骨骼的權重值。
void set_bone_path(index: int, path: NodePath) 🔗
設定與指定骨骼相關聯的節點的路徑。
void set_bone_weights(index: int, weights: PackedFloat32Array) 🔗
設定指定骨骼的權重值。