Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

TileData

继承: Object

TileSet 中单个图块的设置。

描述

TileData 对象代表 TileSet 中的单个图块,通常使用图块集编辑器进行编辑,但也可以在运行时使用 TileMap._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 ( int layer_id )

float

get_collision_polygon_one_way_margin ( int layer_id, int polygon_index ) const

PackedVector2Array

get_collision_polygon_points ( int layer_id, int polygon_index ) const

int

get_collision_polygons_count ( int layer_id ) const

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

Variant

get_custom_data_by_layer_id ( int layer_id ) const

NavigationPolygon

get_navigation_polygon ( int layer_id ) const

OccluderPolygon2D

get_occluder ( int layer_id ) const

int

get_terrain_peering_bit ( CellNeighbor peering_bit ) const

bool

is_collision_polygon_one_way ( int layer_id, int polygon_index ) const

void

remove_collision_polygon ( int layer_id, int polygon_index )

void

set_collision_polygon_one_way ( int layer_id, int polygon_index, bool one_way )

void

set_collision_polygon_one_way_margin ( int layer_id, int polygon_index, float one_way_margin )

void

set_collision_polygon_points ( int layer_id, int polygon_index, PackedVector2Array polygon )

void

set_collision_polygons_count ( int layer_id, int polygons_count )

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 )

void

set_custom_data_by_layer_id ( int layer_id, Variant value )

void

set_navigation_polygon ( int layer_id, NavigationPolygon navigation_polygon )

void

set_occluder ( int layer_id, OccluderPolygon2D occluder_polygon )

void

set_terrain_peering_bit ( CellNeighbor peering_bit, int terrain )


信号

changed ( )

任何属性发生变化时发出。


属性说明

bool flip_h = false

  • void set_flip_h ( bool value )

  • bool get_flip_h ( )

如果为 true,则该图块的纹理会被水平翻转。


bool flip_v = false

  • void set_flip_v ( bool value )

  • bool get_flip_v ( )

如果为 true,则该图块的纹理会被垂直翻转。


Material material

用于此 TileDataMaterial。使用默认着色器可以设为 CanvasItemMaterial,使用自定义着色器可以设为 ShaderMaterial


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

  • void set_modulate ( Color value )

  • Color get_modulate ( )

该图块的颜色调制。


float probability = 1.0

  • void set_probability ( float value )

  • float get_probability ( )

绘制随机图块图案时选择该图块的相对概率。


int terrain = -1

  • void set_terrain ( int value )

  • int get_terrain ( )

该图块所使用的地形集中地形的 ID。


int terrain_set = -1

  • void set_terrain_set ( int value )

  • int get_terrain_set ( )

该图块所使用的地形集的 ID。


Vector2i texture_origin = Vector2i(0, 0)

该图块绘制时的位置偏移量。


bool transpose = false

  • void set_transpose ( bool value )

  • bool get_transpose ( )

如果为 true,则该图块会转置显示,即调换水平和垂直纹理 UV。


int y_sort_origin = 0

  • void set_y_sort_origin ( int value )

  • int get_y_sort_origin ( )

该图块用于确定 Y 排序顺序的垂直点。


int z_index = 0

  • void set_z_index ( int value )

  • int get_z_index ( )

该图块的排序索引,相对于 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 指定。


NavigationPolygon get_navigation_polygon ( int layer_id ) const

返回该图块中索引为 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 指定。


void set_navigation_polygon ( int layer_id, NavigationPolygon navigation_polygon )

设置索引为 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 方向的地形位。