TileData

继承: Object

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 TileMap._tile_data_runtime_update.

属性

方法

voidadd_collision_polygon ( layer_id: int )
voidadd_occluder_polygon ( layer_id: int )
floatget_collision_polygon_one_way_margin ( layer_id: int, polygon_index: int ) const1
PackedVector2Arrayget_collision_polygon_points ( layer_id: int, polygon_index: int ) const1
intget_collision_polygons_count ( layer_id: int ) const1
floatget_constant_angular_velocity ( layer_id: int ) const1
Vector2get_constant_linear_velocity ( layer_id: int ) const1
Variantget_custom_data ( layer_name: String ) const1
Variantget_custom_data_by_layer_id ( layer_id: int ) const1
NavigationPolygonget_navigation_polygon ( layer_id: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false ) const1
OccluderPolygon2Dget_occluder ( layer_id: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false ) const1
OccluderPolygon2Dget_occluder_polygon ( layer_id: int, polygon_index: int, flip_h: bool = false, flip_v: bool = false, transpose: bool = false ) const1
intget_occluder_polygons_count ( layer_id: int ) const1
intget_terrain_peering_bit ( peering_bit: CellNeighbor ) const1
boolis_collision_polygon_one_way ( layer_id: int, polygon_index: int ) const1
boolis_valid_terrain_peering_bit ( peering_bit: CellNeighbor ) const1
voidremove_collision_polygon ( layer_id: int, polygon_index: int )
voidremove_occluder_polygon ( layer_id: int, polygon_index: int )
voidset_collision_polygon_one_way ( layer_id: int, polygon_index: int, one_way: bool )
voidset_collision_polygon_one_way_margin ( layer_id: int, polygon_index: int, one_way_margin: float )
voidset_collision_polygon_points ( layer_id: int, polygon_index: int, polygon: PackedVector2Array )
voidset_collision_polygons_count ( layer_id: int, polygons_count: int )
voidset_constant_angular_velocity ( layer_id: int, velocity: float )
voidset_constant_linear_velocity ( layer_id: int, velocity: Vector2 )
voidset_custom_data ( layer_name: String, value: Variant )
voidset_custom_data_by_layer_id ( layer_id: int, value: Variant )
voidset_navigation_polygon ( layer_id: int, navigation_polygon: NavigationPolygon )
voidset_occluder ( layer_id: int, occluder_polygon: OccluderPolygon2D )
voidset_occluder_polygon ( layer_id: int, polygon_index: int, polygon: OccluderPolygon2D )
voidset_occluder_polygons_count ( layer_id: int, polygons_count: int )
voidset_terrain_peering_bit ( peering_bit: CellNeighbor, terrain: int )

信号

changed ( )

Emitted when any of the properties are changed.


属性说明

bool flip_h = false

  • void set_flip_h ( value: bool )
  • bool get_flip_h ( )

If true, the tile will have its texture flipped horizontally.


bool flip_v = false

  • void set_flip_v ( value: bool )
  • bool get_flip_v ( )

If true, the tile will have its texture flipped vertically.


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.


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

  • void set_modulate ( value: Color )
  • Color get_modulate ( )

Color modulation of the tile.


float probability = 1.0

  • void set_probability ( value: float )
  • float get_probability ( )

Relative probability of this tile being selected when drawing a pattern of random tiles.


int terrain = -1

  • void set_terrain ( value: int )
  • int get_terrain ( )

ID of the terrain from the terrain set that the tile uses.


int terrain_set = -1

  • void set_terrain_set ( value: int )
  • int get_terrain_set ( )

ID of the terrain set that the tile uses.


Vector2i texture_origin = Vector2i(0, 0)

Offsets the position of where the tile is drawn.


bool transpose = false

  • void set_transpose ( value: bool )
  • bool get_transpose ( )

If true, the tile will display transposed, i.e. with horizontal and vertical texture UVs swapped.


int y_sort_origin = 0

  • void set_y_sort_origin ( value: int )
  • int get_y_sort_origin ( )

Vertical point of the tile used for determining y-sorted order.


int z_index = 0

  • void set_z_index ( value: int )
  • int get_z_index ( )

Ordering index of this tile, relative to TileMap.


方法说明

void add_collision_polygon ( layer_id: int )

Adds a collision polygon to the tile on the given TileSet physics layer.


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 ) const1

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


PackedVector2Array get_collision_polygon_points ( layer_id: int, polygon_index: int ) const1

Returns the points of the polygon at index polygon_index for TileSet physics layer with index layer_id.


int get_collision_polygons_count ( layer_id: int ) const1

Returns how many polygons the tile has for TileSet physics layer with index layer_id.


float get_constant_angular_velocity ( layer_id: int ) const1

Returns the constant angular velocity applied to objects colliding with this tile.


Vector2 get_constant_linear_velocity ( layer_id: int ) const1

Returns the constant linear velocity applied to objects colliding with this tile.


Variant get_custom_data ( layer_name: String ) const1

Returns the custom data value for custom data layer named layer_name.


Variant get_custom_data_by_layer_id ( layer_id: int ) const1

Returns the custom data value for custom data layer with index layer_id.


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

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 ) const1

已弃用: 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 ) const1

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 ) const1

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 ) const1

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 is_collision_polygon_one_way ( layer_id: int, polygon_index: int ) const1

Returns whether one-way collisions are enabled for the polygon at index polygon_index for TileSet physics layer with index layer_id.


bool is_valid_terrain_peering_bit ( peering_bit: CellNeighbor ) const1

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


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.


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 )

Enables/disables one-way collisions on the polygon at index polygon_index for TileSet physics layer with index layer_id.


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 )

Sets the points of the polygon at index polygon_index for TileSet physics layer with index layer_id.


void set_collision_polygons_count ( layer_id: int, polygons_count: int )

Sets the polygons count for TileSet physics layer with index layer_id.


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.


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.


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.


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.


void set_navigation_polygon ( layer_id: int, navigation_polygon: NavigationPolygon )

Sets the navigation polygon for the TileSet navigation layer with index layer_id.


void set_occluder ( layer_id: int, occluder_polygon: OccluderPolygon2D )

已弃用: Use set_occluder_polygon instead.

Sets the occluder for the TileSet occlusion layer with index layer_id.


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.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。