TileData
Inherits: Object
Description
Section titled “Description”Settings for a single tile in a 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().
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| 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 |
Methods
Section titled “Methods”Signals
Section titled “Signals”changed
changed()
Emitted when any of the properties are changed.
Property descriptions
Section titled “Property descriptions”flip_h
bool flip_h = false
If true, the tile will have its texture flipped horizontally.
flip_v
bool flip_v = false
If true, the tile will have its texture flipped vertically.
material
Material material
The Material to use for this TileData. This can be a CanvasItemMaterial to use the default shader, or a ShaderMaterial to use a custom shader.
modulate
Color modulate = Color(1, 1, 1, 1)
Color modulation of the tile.
probability
float probability = 1.0
Relative probability of this tile being selected when drawing a pattern of random tiles.
terrain
int terrain = -1
ID of the terrain from the terrain set that the tile uses.
terrain_set
int terrain_set = -1
ID of the terrain set that the tile uses.
texture_origin
Vector2i texture_origin = Vector2i(0, 0)
Offsets the position of where the tile is drawn.
transpose
bool transpose = false
If true, the tile will display transposed, i.e. with horizontal and vertical texture UVs swapped.
y_sort_origin
int y_sort_origin = 0
Vertical point of the tile used for determining y-sorted order.
z_index
int z_index = 0
Ordering index of this tile, relative to TileMapLayer.
Method descriptions
Section titled “Method descriptions”add_collision_polygon
void add_collision_polygon(layer_id: int)
Adds a collision polygon to the tile on the given TileSet physics layer.
add_occluder_polygon
void add_occluder_polygon(layer_id: int)
Adds an occlusion polygon to the tile on the TileSet occlusion layer with index layer_id.
get_collision_polygon_one_way_margin
float get_collision_polygon_one_way_margin(layer_id: int, polygon_index: int) const
Returns the one-way margin (for one-way platforms) of the polygon at index polygon_index for TileSet physics layer with index layer_id.
get_collision_polygon_points
PackedVector2Array get_collision_polygon_points(layer_id: int, polygon_index: int) const
Returns the points of the polygon at index polygon_index for TileSet physics layer with index layer_id.
get_collision_polygons_count
int get_collision_polygons_count(layer_id: int) const
Returns how many polygons the tile has for TileSet physics layer with index layer_id.
get_constant_angular_velocity
float get_constant_angular_velocity(layer_id: int) const
Returns the constant angular velocity applied to objects colliding with this tile.
get_constant_linear_velocity
Vector2 get_constant_linear_velocity(layer_id: int) const
Returns the constant linear velocity applied to objects colliding with this tile.
get_custom_data
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().
get_custom_data_by_layer_id
Variant get_custom_data_by_layer_id(layer_id: int) const
Returns the custom data value for custom data layer with index layer_id.
get_navigation_polygon
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.
get_occluder_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.
get_occluder_polygons_count
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.
get_terrain_peering_bit
int get_terrain_peering_bit(peering_bit: TileSet.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().
has_custom_data
bool has_custom_data(layer_name: String) const
Returns whether there exists a custom data layer named layer_name.
is_collision_polygon_one_way
bool is_collision_polygon_one_way(layer_id: int, polygon_index: int) const
Returns whether one-way collisions are enabled for the polygon at index polygon_index for TileSet physics layer with index layer_id.
is_valid_terrain_peering_bit
bool is_valid_terrain_peering_bit(peering_bit: TileSet.CellNeighbor) const
Returns whether the given peering_bit direction is valid for this tile.
remove_collision_polygon
void remove_collision_polygon(layer_id: int, polygon_index: int)
Removes the polygon at index polygon_index for TileSet physics layer with index layer_id.
remove_occluder_polygon
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.
set_collision_polygon_one_way
void set_collision_polygon_one_way(layer_id: int, polygon_index: int, one_way: bool)
Enables/disables one-way collisions on the polygon at index polygon_index for TileSet physics layer with index layer_id.
set_collision_polygon_one_way_margin
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.
set_collision_polygon_points
void set_collision_polygon_points(layer_id: int, polygon_index: int, polygon: PackedVector2Array)
Sets the points of the polygon at index polygon_index for TileSet physics layer with index layer_id.
set_collision_polygons_count
void set_collision_polygons_count(layer_id: int, polygons_count: int)
Sets the polygons count for TileSet physics layer with index layer_id.
set_constant_angular_velocity
void set_constant_angular_velocity(layer_id: int, velocity: float)
Sets the constant angular velocity. This does not rotate the tile. This angular velocity is applied to objects colliding with this tile.
set_constant_linear_velocity
void set_constant_linear_velocity(layer_id: int, velocity: Vector2)
Sets the constant linear velocity. This does not move the tile. This linear velocity is applied to objects colliding with this tile. This is useful to create conveyor belts.
set_custom_data
void set_custom_data(layer_name: String, value: Variant)
Sets the tile’s custom data value for the TileSet custom data layer with name layer_name.
set_custom_data_by_layer_id
void set_custom_data_by_layer_id(layer_id: int, value: Variant)
Sets the tile’s custom data value for the TileSet custom data layer with index layer_id.
set_navigation_polygon
void set_navigation_polygon(layer_id: int, navigation_polygon: NavigationPolygon)
Sets the navigation polygon for the TileSet navigation layer with index layer_id.
set_occluder_polygon
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.
set_occluder_polygons_count
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.
set_terrain_peering_bit
void set_terrain_peering_bit(peering_bit: TileSet.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().
