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...
TileData¶
继承: Object
TileSet 中单个图块的设置。
描述¶
TileData 对象代表 TileSet 中的单个图块,通常使用图块集编辑器进行编辑,但也可以在运行时使用 TileMap._tile_data_runtime_update 进行修改。
属性¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法¶
信号¶
changed ( )
任何属性发生变化时发出。
属性说明¶
bool flip_h = false
如果为 true
,则该图块的纹理会被水平翻转。
bool flip_v = false
如果为 true
,则该图块的纹理会被垂直翻转。
Material material
用于此 TileData 的 Material。使用默认着色器可以设为 CanvasItemMaterial,使用自定义着色器可以设为 ShaderMaterial。
Color modulate = Color(1, 1, 1, 1)
该图块的颜色调制。
float probability = 1.0
绘制随机图块图案时选择该图块的相对概率。
int terrain = -1
该图块所使用的地形集中地形的 ID。
int terrain_set = -1
该图块所使用的地形集的 ID。
Vector2i texture_origin = Vector2i(0, 0)
该图块绘制时的位置偏移量。
bool transpose = false
如果为 true
,则该图块会转置显示,即调换水平和垂直纹理 UV。
int y_sort_origin = 0
该图块用于确定 Y 排序顺序的垂直点。
int z_index = 0
该图块的排序索引,相对于 TileMap。
方法说明¶
void add_collision_polygon ( int layer_id )
为该图块在给定的 TileSet 物理层上添加碰撞多边形。
float get_collision_polygon_one_way_margin ( int layer_id, int polygon_index ) const
返回在索引为 layer_id
的 TileSet 物理层上,索引为 polygon_index
的多边形的单向边距(用于单向平台)。
PackedVector2Array get_collision_polygon_points ( int layer_id, int polygon_index ) const
返回在索引为 layer_id
的 TileSet 物理层上,索引为 polygon_index
的多边形的点。
int get_collision_polygons_count ( int layer_id ) const
设置该图块中索引为 layer_id
的 TileSet 物理层中多边形的数量。
float get_constant_angular_velocity ( int layer_id ) const
返回恒定角速度,将应用于与此图块碰撞的对象。
Vector2 get_constant_linear_velocity ( int layer_id ) const
返回恒定线速度,将应用于与此图块碰撞的对象。
Variant get_custom_data ( String layer_name ) const
返回自定义数据层的自定义数据值,自定义数据层用名称 layer_name
指定。
Variant get_custom_data_by_layer_id ( int layer_id ) const
返回自定义数据层的自定义数据值,自定义数据层用索引 layer_id
指定。
返回该图块中索引为 layer_id
的 TileSet 导航层的导航多边形。
OccluderPolygon2D get_occluder ( int layer_id ) const
返回该图块中索引为 layer_id
的 TileSet 遮挡层的遮挡器多边形。
int get_terrain_peering_bit ( CellNeighbor peering_bit ) const
返回该图块给定 peering_bit
方向的地形位。
bool is_collision_polygon_one_way ( int layer_id, int polygon_index ) const
返回索引为 layer_id
的 TileSet 物理层上索引为 polygon_index
的多边形是否启用了单向碰撞。
void remove_collision_polygon ( int layer_id, int polygon_index )
移除索引为 layer_id
的 TileSet 物理层上索引为 polygon_index
的多边形。
void set_collision_polygon_one_way ( int layer_id, int polygon_index, bool one_way )
启用/禁用索引为 layer_id
的 TileSet 物理层上索引为 polygon_index
的多边形的单向碰撞。
void set_collision_polygon_one_way_margin ( int layer_id, int polygon_index, float one_way_margin )
启用/禁用索引为 layer_id
的 TileSet 物理层上索引为 polygon_index
的多边形的单向碰撞。
void set_collision_polygon_points ( int layer_id, int polygon_index, PackedVector2Array polygon )
设置索引为 layer_id
的 TileSet 物理层上索引为 polygon_index
的多边形的顶点。
void set_collision_polygons_count ( int layer_id, int polygons_count )
设置索引为 layer_id
的 TileSet 物理层中多边形的数量。
void set_constant_angular_velocity ( int layer_id, float velocity )
设置恒定角速度。不会旋转图块。会对与该图块发生碰撞的对象应用该角速度。
void set_constant_linear_velocity ( int layer_id, Vector2 velocity )
设置恒定线速度。不会旋转图块。会对与该图块发生碰撞的对象应用该线速度。可用于创建传送带。
void set_custom_data ( String layer_name, Variant value )
设置该图块的自定义数据值,TileSet 自定义数据层由名称 layer_name
指定。
void set_custom_data_by_layer_id ( int layer_id, Variant value )
设置该图块的自定义数据值,TileSet 自定义数据层由索引 layer_id
指定。
设置索引为 layer_id
的 TileSet 导航层的导航多边形。
void set_occluder ( int layer_id, OccluderPolygon2D occluder_polygon )
设置索引为 layer_id
的 TileSet 遮挡层的遮挡器。
void set_terrain_peering_bit ( CellNeighbor peering_bit, int terrain )
设置该图块给定 peering_bit
方向的地形位。