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...
TileMap¶
Inherits: Node2D < CanvasItem < Node < Object
Node for 2D tile-based maps.
Description¶
Node for 2D tile-based maps. Tilemaps use a TileSet which contain a list of tiles which are used to create grid-based maps. A TileMap may have several layers, layouting tiles on top of each other.
For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a TileSetScenesCollectionSource may be initialized after their parent.
To force an update earlier on, call update_internals.
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
Methods¶
void |
_tile_data_runtime_update ( int layer, Vector2i coords, TileData tile_data ) virtual |
_use_tile_data_runtime_update ( int layer, Vector2i coords ) virtual |
|
void |
|
void |
clear ( ) |
void |
clear_layer ( int layer ) |
void |
erase_cell ( int layer, Vector2i coords ) |
void |
|
void |
force_update ( int layer=-1 ) |
get_cell_alternative_tile ( int layer, Vector2i coords, bool use_proxies=false ) const |
|
get_cell_atlas_coords ( int layer, Vector2i coords, bool use_proxies=false ) const |
|
get_cell_source_id ( int layer, Vector2i coords, bool use_proxies=false ) const |
|
get_cell_tile_data ( int layer, Vector2i coords, bool use_proxies=false ) const |
|
get_coords_for_body_rid ( RID body ) |
|
get_layer_for_body_rid ( RID body ) |
|
get_layer_modulate ( int layer ) const |
|
get_layer_name ( int layer ) const |
|
get_layer_navigation_map ( int layer ) const |
|
get_layer_y_sort_origin ( int layer ) const |
|
get_layer_z_index ( int layer ) const |
|
get_layers_count ( ) const |
|
get_navigation_map ( int layer ) const |
|
get_neighbor_cell ( Vector2i coords, CellNeighbor neighbor ) const |
|
get_pattern ( int layer, Vector2i[] coords_array ) |
|
get_surrounding_cells ( Vector2i coords ) |
|
get_used_cells ( int layer ) const |
|
get_used_cells_by_id ( int layer, int source_id=-1, Vector2i atlas_coords=Vector2i(-1, -1), int alternative_tile=-1 ) const |
|
get_used_rect ( ) const |
|
is_layer_enabled ( int layer ) const |
|
is_layer_navigation_enabled ( int layer ) const |
|
is_layer_y_sort_enabled ( int layer ) const |
|
local_to_map ( Vector2 local_position ) const |
|
map_pattern ( Vector2i position_in_tilemap, Vector2i coords_in_pattern, TileMapPattern pattern ) |
|
map_to_local ( Vector2i map_position ) const |
|
void |
move_layer ( int layer, int to_position ) |
void |
notify_runtime_tile_data_update ( int layer=-1 ) |
void |
remove_layer ( int layer ) |
void |
set_cell ( int layer, Vector2i coords, int source_id=-1, Vector2i atlas_coords=Vector2i(-1, -1), int alternative_tile=0 ) |
void |
set_cells_terrain_connect ( int layer, Vector2i[] cells, int terrain_set, int terrain, bool ignore_empty_terrains=true ) |
void |
set_cells_terrain_path ( int layer, Vector2i[] path, int terrain_set, int terrain, bool ignore_empty_terrains=true ) |
void |
set_layer_enabled ( int layer, bool enabled ) |
void |
set_layer_modulate ( int layer, Color modulate ) |
void |
set_layer_name ( int layer, String name ) |
void |
set_layer_navigation_enabled ( int layer, bool enabled ) |
void |
set_layer_navigation_map ( int layer, RID map ) |
void |
set_layer_y_sort_enabled ( int layer, bool y_sort_enabled ) |
void |
set_layer_y_sort_origin ( int layer, int y_sort_origin ) |
void |
set_layer_z_index ( int layer, int z_index ) |
void |
set_navigation_map ( int layer, RID map ) |
void |
set_pattern ( int layer, Vector2i position, TileMapPattern pattern ) |
void |
update_internals ( ) |
Signals¶
changed ( )
Emitted when the TileSet of this TileMap changes.
Enumerations¶
enum VisibilityMode:
VisibilityMode VISIBILITY_MODE_DEFAULT = 0
Use the debug settings to determine visibility.
VisibilityMode VISIBILITY_MODE_FORCE_HIDE = 2
Always hide.
VisibilityMode VISIBILITY_MODE_FORCE_SHOW = 1
Always show.
Property Descriptions¶
bool collision_animatable = false
If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform.
Note: Enabling collision_animatable may have a small performance impact, only do it if the TileMap is moving and has colliding tiles.
VisibilityMode collision_visibility_mode = 0
void set_collision_visibility_mode ( VisibilityMode value )
VisibilityMode get_collision_visibility_mode ( )
Show or hide the TileMap's collision shapes. If set to VISIBILITY_MODE_DEFAULT, this depends on the show collision debug settings.
void set_navigation_visibility_mode ( VisibilityMode value )
VisibilityMode get_navigation_visibility_mode ( )
Show or hide the TileMap's navigation meshes. If set to VISIBILITY_MODE_DEFAULT, this depends on the show navigation debug settings.
int rendering_quadrant_size = 16
The TileMap's quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes. rendering_quadrant_size defines the length of a square's side, in the map's coordinate system, that forms the quadrant. Thus, the default quandrant size groups together 16 * 16 = 256
tiles.
The quadrant size does not apply on Y-sorted layers, as tiles are be grouped by Y position instead in that case.
Note: As quadrants are created according to the map's coordinate system, the quadrant's "square shape" might not look like square in the TileMap's local coordinate system.
TileSet tile_set
The assigned TileSet.
Method Descriptions¶
void _tile_data_runtime_update ( int layer, Vector2i coords, TileData tile_data ) virtual
Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime.
This method is only called if _use_tile_data_runtime_update is implemented and returns true
for the given tile coords
and layer
.
Warning: The tile_data
object's sub-resources are the same as the one in the TileSet. Modifying them might impact the whole TileSet. Instead, make sure to duplicate those resources.
Note: If the properties of tile_data
object should change over time, use notify_runtime_tile_data_update to notify the TileMap it needs an update.
bool _use_tile_data_runtime_update ( int layer, Vector2i coords ) virtual
Should return true
if the tile at coordinates coords
on layer layer
requires a runtime update.
Warning: Make sure this function only return true
when needed. Any tile processed at runtime without a need for it will imply a significant performance penalty.
Note: If the result of this function should changed, use notify_runtime_tile_data_update to notify the TileMap it needs an update.
void add_layer ( int to_position )
Adds a layer at the given position to_position
in the array. If to_position
is negative, the position is counted from the end, with