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.

TileData

繼承: Object

TileSet 中單個圖塊的設定。

說明

TileData object represents a single tile in a TileSet. It is usually edited using the tileset editor, but it can be modified at runtime using TileMapLayer._tile_data_runtime_update().

屬性

bool

flip_h

false

bool

flip_v

false

Material

material

Color

modulate

Color(1, 1, 1, 1)

float

probability

1.0

int

terrain

-1

int

terrain_set

-1

Vector2i

texture_origin

Vector2i(0, 0)

bool

transpose

false

int

y_sort_origin

0

int

z_index

0

方法

void

add_collision_polygon(layer_id: int)

void

add_occluder_polygon(layer_id: int)

float

get_collision_polygon_one_way_margin(layer_id: int, polygon_index: int) const

PackedVector2Array

get_collision_polygon_points(layer_id: int, polygon_index: int) const

int

get_collision_polygons_count(layer_id: int) const

float

get_constant_angular_velocity(layer_id: int) const

Vector2

get_constant_linear_velocity(layer_id: int) const

Variant

get_custom_data(layer_name: String) const

Variant

get_custom_data_by_layer_id(layer_id: int) const

NavigationPolygon

get_navigation_polygon(layer_id: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false) const

OccluderPolygon2D

get_occluder(layer_id: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false) const

OccluderPolygon2D

get_occluder_polygon(layer_id: int, polygon_index: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false) const

int

get_occluder_polygons_count(layer_id: int) const

int

get_terrain_peering_bit(peering_bit: CellNeighbor) const

bool

has_custom_data(layer_name: String) const

bool

is_collision_polygon_one_way(layer_id: int, polygon_index: int) const

bool

is_valid_terrain_peering_bit(peering_bit: CellNeighbor) const

void

remove_collision_polygon(layer_id: int, polygon_index: int)

void

remove_occluder_polygon(layer_id: int, polygon_index: int)

void

set_collision_polygon_one_way(layer_id: int, polygon_index: int, one_way: bool)

void

set_collision_polygon_one_way_margin(layer_id: int, polygon_index: int, one_way_margin: float)

void

set_collision_polygon_points(layer_id: int, polygon_index: int, polygon: PackedVector2Array)

void

set_collision_polygons_count(layer_id: int, polygons_count: int)

void

set_constant_angular_velocity(layer_id: int, velocity: float)

void

set_constant_linear_velocity(layer_id: int, velocity: Vector2)

void

set_custom_data(layer_name: String, value: Variant)

void

set_custom_data_by_layer_id(layer_id: int, value: Variant)

void

set_navigation_polygon(layer_id: int, navigation_polygon: NavigationPolygon)

void

set_occluder(layer_id: int, occluder_polygon: OccluderPolygon2D)

void

set_occluder_polygon(layer_id: int, polygon_index: int, polygon: OccluderPolygon2D)

void

set_occluder_polygons_count(layer_id: int, polygons_count: int)

void

set_terrain_peering_bit(peering_bit: CellNeighbor, terrain: int)


訊號

changed() 🔗

任何屬性發生變化時發出。


屬性說明

bool flip_h = false 🔗

  • void set_flip_h(value: bool)

  • bool get_flip_h()

如果為 true,則該圖塊的紋理會被水平翻轉。


bool flip_v = false 🔗

  • void set_flip_v(value: bool)

  • bool get_flip_v()

如果為 true,則該圖塊的紋理會被垂直翻轉。


Material material 🔗

用於此 TileDataMaterial。使用預設著色器可以設為 CanvasItemMaterial,使用自訂著色器可以設為 ShaderMaterial


Color modulate = Color(1, 1, 1, 1) 🔗

  • void set_modulate(value: Color)

  • Color get_modulate()

該圖塊的顏色調變。


float probability = 1.0 🔗

  • void set_probability(value: float)

  • float get_probability()

繪製隨機圖塊圖案時選擇該圖塊的相對概率。


int terrain = -1 🔗

  • void set_terrain(value: int)

  • int get_terrain()

該圖塊所使用的地形集中地形的 ID。


int terrain_set = -1 🔗

  • void set_terrain_set(value: int)

  • int get_terrain_set()

該圖塊所使用的地形集的 ID。


Vector2i texture_origin = Vector2i(0, 0) 🔗

該圖塊繪製時的位置偏移量。


bool transpose = false 🔗

  • void set_transpose(value: bool)

  • bool get_transpose()

如果為 true,則該圖塊會轉置顯示,即調換水平和垂直紋理 UV。


int y_sort_origin = 0 🔗

  • void set_y_sort_origin(value: int)

  • int get_y_sort_origin()

該圖塊用於確定 Y 排序順序的垂直點。


int z_index = 0 🔗

  • void set_z_index(value: int)

  • int get_z_index()

Ordering index of this tile, relative to TileMapLayer.


方法說明

void add_collision_polygon(layer_id: int) 🔗

為該圖塊在給定的 TileSet 實體層上新增碰撞多邊形。


void add_occluder_polygon(layer_id: int) 🔗

Adds an occlusion polygon to the tile on the TileSet occlusion layer with index layer_id.


float get_collision_polygon_one_way_margin(layer_id: int, polygon_index: int) const 🔗

返回在索引為 layer_id 的 TileSet 實體層上,索引為 polygon_index 的多邊形的單向邊距(用於單向平臺)。


PackedVector2Array get_collision_polygon_points(layer_id: int, polygon_index: int) const 🔗

返回在索引為 layer_id 的 TileSet 實體層上,索引為 polygon_index 的多邊形的點。


int get_collision_polygons_count(layer_id: int) const 🔗

設定該圖塊中索引為 layer_id 的 TileSet 實體層中多邊形的數量。


float get_constant_angular_velocity(layer_id: int) const 🔗

返回恒定角速度,將套用於與此圖塊碰撞的物件。


Vector2 get_constant_linear_velocity(layer_id: int) const 🔗

返回恒定線速度,將套用於與此圖塊碰撞的物件。


Variant get_custom_data(layer_name: String) const 🔗

Returns the custom data value for custom data layer named layer_name. To check if a custom data layer exists, use has_custom_data().


Variant get_custom_data_by_layer_id(layer_id: int) const 🔗

返回自訂資料層的自訂資料值,自訂資料層用索引 layer_id 指定。


NavigationPolygon get_navigation_polygon(layer_id: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false) const 🔗

Returns the navigation polygon of the tile for the TileSet navigation layer with index layer_id.

flip_h, flip_v, and transpose allow transforming the returned polygon.


OccluderPolygon2D get_occluder(layer_id: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false) const 🔗

已棄用: Use get_occluder_polygon() instead.

Returns the occluder polygon of the tile for the TileSet occlusion layer with index layer_id.

flip_h, flip_v, and transpose allow transforming the returned polygon.


OccluderPolygon2D get_occluder_polygon(layer_id: int, polygon_index: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false) const 🔗

Returns the occluder polygon at index polygon_index from the TileSet occlusion layer with index layer_id.

The flip_h, flip_v, and transpose parameters can be true to transform the returned polygon.


int get_occluder_polygons_count(layer_id: int) const 🔗

Returns the number of occluder polygons of the tile in the TileSet occlusion layer with index layer_id.


int get_terrain_peering_bit(peering_bit: CellNeighbor) const 🔗

Returns the tile's terrain bit for the given peering_bit direction. To check that a direction is valid, use is_valid_terrain_peering_bit().


bool has_custom_data(layer_name: String) const 🔗

Returns whether there exists a custom data layer named layer_name.


bool is_collision_polygon_one_way(layer_id: int, polygon_index: int) const 🔗

返回索引為 layer_id 的 TileSet 實體層上索引為 polygon_index 的多邊形是否啟用了單向碰撞。


bool is_valid_terrain_peering_bit(peering_bit: CellNeighbor) const 🔗

Returns whether the given peering_bit direction is valid for this tile.


void remove_collision_polygon(layer_id: int, polygon_index: int) 🔗

移除索引為 layer_id 的 TileSet 實體層上索引為 polygon_index 的多邊形。


void remove_occluder_polygon(layer_id: int, polygon_index: int) 🔗

Removes the polygon at index polygon_index for TileSet occlusion layer with index layer_id.


void set_collision_polygon_one_way(layer_id: int, polygon_index: int, one_way: bool) 🔗

啟用/禁用索引為 layer_id 的 TileSet 實體層上索引為 polygon_index 的多邊形的單向碰撞。


void set_collision_polygon_one_way_margin(layer_id: int, polygon_index: int, one_way_margin: float) 🔗

Sets the one-way margin (for one-way platforms) of the polygon at index polygon_index for TileSet physics layer with index layer_id.


void set_collision_polygon_points(layer_id: int, polygon_index: int, polygon: PackedVector2Array) 🔗

設定索引為 layer_id 的 TileSet 實體層上索引為 polygon_index 的多邊形的頂點。


void set_collision_polygons_count(layer_id: int, polygons_count: int) 🔗

設定索引為 layer_id 的 TileSet 實體層中多邊形的數量。


void set_constant_angular_velocity(layer_id: int, velocity: float) 🔗

設定恒定角速度。不會旋轉圖塊。會對與該圖塊發生碰撞的物件套用該角速度。


void set_constant_linear_velocity(layer_id: int, velocity: Vector2) 🔗

設定恒定線速度。不會旋轉圖塊。會對與該圖塊發生碰撞的物件套用該線速度。可用於建立傳送帶。


void set_custom_data(layer_name: String, value: Variant) 🔗

設定該圖塊的自訂資料值,TileSet 自訂資料層由名稱 layer_name 指定。


void set_custom_data_by_layer_id(layer_id: int, value: Variant) 🔗

設定該圖塊的自訂資料值,TileSet 自訂資料層由索引 layer_id 指定。


void set_navigation_polygon(layer_id: int, navigation_polygon: NavigationPolygon) 🔗

設定索引為 layer_id 的 TileSet 導覽層的導覽多邊形。


void set_occluder(layer_id: int, occluder_polygon: OccluderPolygon2D) 🔗

已棄用: Use set_occluder_polygon() instead.

設定索引為 layer_id 的 TileSet 遮擋層的遮擋器。


void set_occluder_polygon(layer_id: int, polygon_index: int, polygon: OccluderPolygon2D) 🔗

Sets the occluder for polygon with index polygon_index in the TileSet occlusion layer with index layer_id.


void set_occluder_polygons_count(layer_id: int, polygons_count: int) 🔗

Sets the occluder polygon count in the TileSet occlusion layer with index layer_id.


void set_terrain_peering_bit(peering_bit: CellNeighbor, terrain: int) 🔗

Sets the tile's terrain bit for the given peering_bit direction. To check that a direction is valid, use is_valid_terrain_peering_bit().