:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the TileMap.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_TileMap: TileMap ======= **Inherits:** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` Node for 2D tile-based maps. Description ----------- Node for 2D tile-based maps. Tilemaps use a :ref:`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. Tutorials --------- - :doc:`Using Tilemaps <../tutorials/2d/using_tilemaps>` - `2D Platformer Demo `__ - `2D Isometric Demo `__ - `2D Hexagonal Demo `__ - `2D Navigation Astar Demo `__ - `2D Role Playing Game Demo `__ - `2D Kinematic Character Demo `__ Properties ---------- +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+ | :ref:`int` | :ref:`cell_quadrant_size` | ``16`` | +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`collision_animatable` | ``false`` | +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+ | :ref:`VisibilityMode` | :ref:`collision_visibility_mode` | ``0`` | +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+ | :ref:`VisibilityMode` | :ref:`navigation_visibility_mode` | ``0`` | +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+ | :ref:`TileSet` | :ref:`tile_set` | | +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+ Methods ------- +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`_tile_data_runtime_update` **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`TileData` tile_data **)** |virtual| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_use_tile_data_runtime_update` **(** :ref:`int` layer, :ref:`Vector2i` coords **)** |virtual| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_layer` **(** :ref:`int` to_position **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear_layer` **(** :ref:`int` layer **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`erase_cell` **(** :ref:`int` layer, :ref:`Vector2i` coords **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`fix_invalid_tiles` **(** **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`force_update` **(** :ref:`int` layer=-1 **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_cell_alternative_tile` **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`bool` use_proxies **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i` | :ref:`get_cell_atlas_coords` **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`bool` use_proxies **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_cell_source_id` **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`bool` use_proxies **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i` | :ref:`get_coords_for_body_rid` **(** :ref:`RID` body **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_layer_modulate` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_layer_name` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_layer_y_sort_origin` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_layer_z_index` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_layers_count` **(** **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i` | :ref:`get_neighbor_cell` **(** :ref:`Vector2i` coords, :ref:`CellNeighbor` neighbor **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TileMapPattern` | :ref:`get_pattern` **(** :ref:`int` layer, :ref:`Vector2i[]` coords_array **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i[]` | :ref:`get_surrounding_tiles` **(** :ref:`Vector2i` coords **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i[]` | :ref:`get_used_cells` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Rect2` | :ref:`get_used_rect` **(** **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_layer_enabled` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_layer_y_sort_enabled` **(** :ref:`int` layer **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i` | :ref:`map_pattern` **(** :ref:`Vector2i` position_in_tilemap, :ref:`Vector2i` coords_in_pattern, :ref:`TileMapPattern` pattern **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`map_to_world` **(** :ref:`Vector2i` map_position **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`move_layer` **(** :ref:`int` layer, :ref:`int` to_position **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_layer` **(** :ref:`int` layer **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_cell` **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`int` source_id=-1, :ref:`Vector2i` atlas_coords=Vector2i(-1, -1), :ref:`int` alternative_tile=0 **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_cells_from_surrounding_terrains` **(** :ref:`int` layer, :ref:`Vector2i[]` cells, :ref:`int` terrain_set, :ref:`bool` ignore_empty_terrains=true **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_layer_enabled` **(** :ref:`int` layer, :ref:`bool` enabled **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_layer_modulate` **(** :ref:`int` layer, :ref:`Color` enabled **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_layer_name` **(** :ref:`int` layer, :ref:`String` name **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_layer_y_sort_enabled` **(** :ref:`int` layer, :ref:`bool` y_sort_enabled **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_layer_y_sort_origin` **(** :ref:`int` layer, :ref:`int` y_sort_origin **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_layer_z_index` **(** :ref:`int` layer, :ref:`int` z_index **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_pattern` **(** :ref:`int` layer, :ref:`Vector2i` position, :ref:`TileMapPattern` pattern **)** | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2i` | :ref:`world_to_map` **(** :ref:`Vector2` world_position **)** |const| | +---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Signals ------- .. _class_TileMap_signal_changed: - **changed** **(** **)** Emitted when the :ref:`TileSet` of this TileMap changes. Enumerations ------------ .. _enum_TileMap_VisibilityMode: .. _class_TileMap_constant_VISIBILITY_MODE_DEFAULT: .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_HIDE: .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_SHOW: enum **VisibilityMode**: - **VISIBILITY_MODE_DEFAULT** = **0** --- Use the debug settings to determine visibility. - **VISIBILITY_MODE_FORCE_HIDE** = **2** --- Always hide. - **VISIBILITY_MODE_FORCE_SHOW** = **1** --- Always show. Property Descriptions --------------------- .. _class_TileMap_property_cell_quadrant_size: - :ref:`int` **cell_quadrant_size** +-----------+--------------------------+ | *Default* | ``16`` | +-----------+--------------------------+ | *Setter* | set_quadrant_size(value) | +-----------+--------------------------+ | *Getter* | get_quadrant_size() | +-----------+--------------------------+ The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. ---- .. _class_TileMap_property_collision_animatable: - :ref:`bool` **collision_animatable** +-----------+---------------------------------+ | *Default* | ``false`` | +-----------+---------------------------------+ | *Setter* | set_collision_animatable(value) | +-----------+---------------------------------+ | *Getter* | is_collision_animatable() | +-----------+---------------------------------+ 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. ---- .. _class_TileMap_property_collision_visibility_mode: - :ref:`VisibilityMode` **collision_visibility_mode** +-----------+--------------------------------------+ | *Default* | ``0`` | +-----------+--------------------------------------+ | *Setter* | set_collision_visibility_mode(value) | +-----------+--------------------------------------+ | *Getter* | 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. ---- .. _class_TileMap_property_navigation_visibility_mode: - :ref:`VisibilityMode` **navigation_visibility_mode** +-----------+---------------------------------------+ | *Default* | ``0`` | +-----------+---------------------------------------+ | *Setter* | set_navigation_visibility_mode(value) | +-----------+---------------------------------------+ | *Getter* | get_navigation_visibility_mode() | +-----------+---------------------------------------+ Show or hide the TileMap's collision shapes. If set to ``VISIBILITY_MODE_DEFAULT``, this depends on the show navigation debug settings. ---- .. _class_TileMap_property_tile_set: - :ref:`TileSet` **tile_set** +----------+--------------------+ | *Setter* | set_tileset(value) | +----------+--------------------+ | *Getter* | get_tileset() | +----------+--------------------+ The assigned :ref:`TileSet`. Method Descriptions ------------------- .. _class_TileMap_method__tile_data_runtime_update: - void **_tile_data_runtime_update** **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`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 :ref:`_use_tile_data_runtime_update` is implemented and returns ``true`` for the given tile ``coords[/coords] and [code]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 :ref:`force_update` to trigger a TileMap update. ---- .. _class_TileMap_method__use_tile_data_runtime_update: - :ref:`bool` **_use_tile_data_runtime_update** **(** :ref:`int` layer, :ref:`Vector2i` coords **)** |virtual| Should return ``true`` if the tile at coordinates ``coords[/coords] on layer [code]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. ---- .. _class_TileMap_method_add_layer: - void **add_layer** **(** :ref:`int` to_position **)** Adds a layer at the given position ``to_position`` in the array. If ``to_position`` is -1, adds it at the end of the array. ---- .. _class_TileMap_method_clear: - void **clear** **(** **)** Clears all cells. ---- .. _class_TileMap_method_clear_layer: - void **clear_layer** **(** :ref:`int` layer **)** Clears all cells on the given layer. ---- .. _class_TileMap_method_erase_cell: - void **erase_cell** **(** :ref:`int` layer, :ref:`Vector2i` coords **)** Erases the cell on layer ``layer`` at coordinates ``coords``. ---- .. _class_TileMap_method_fix_invalid_tiles: - void **fix_invalid_tiles** **(** **)** Clears cells that do not exist in the tileset. ---- .. _class_TileMap_method_force_update: - void **force_update** **(** :ref:`int` layer=-1 **)** Triggers an update of the TileMap. If ``layer`` is provided, only updates the given layer. \ **Note:** The TileMap node updates automatically when one of its properties is modified. A manual update is only needed if runtime modifications (implemented in :ref:`_tile_data_runtime_update`) need to be applied. \ **Warning:** Updating the TileMap is a performance demanding task. Limit occurrences of those updates to the minimum and limit the amount tiles they impact (by segregating tiles updated often to a dedicated layer for example). ---- .. _class_TileMap_method_get_cell_alternative_tile: - :ref:`int` **get_cell_alternative_tile** **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`bool` use_proxies **)** |const| Returns the tile alternative ID of the cell on layer ``layer`` at ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy`. ---- .. _class_TileMap_method_get_cell_atlas_coords: - :ref:`Vector2i` **get_cell_atlas_coords** **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`bool` use_proxies **)** |const| Returns the tile atlas coordinates ID of the cell on layer ``layer`` at coordinates ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy`. ---- .. _class_TileMap_method_get_cell_source_id: - :ref:`int` **get_cell_source_id** **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`bool` use_proxies **)** |const| Returns the tile source ID of the cell on layer ``layer`` at coordinates ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy`. ---- .. _class_TileMap_method_get_coords_for_body_rid: - :ref:`Vector2i` **get_coords_for_body_rid** **(** :ref:`RID` body **)** Returns the coordinates of the tile for given physics body RID. Such RID can be retrieved from :ref:`KinematicCollision2D.get_collider_rid`, when colliding with a tile. ---- .. _class_TileMap_method_get_layer_modulate: - :ref:`Color` **get_layer_modulate** **(** :ref:`int` layer **)** |const| Returns a TileMap layer's modulate. ---- .. _class_TileMap_method_get_layer_name: - :ref:`String` **get_layer_name** **(** :ref:`int` layer **)** |const| Returns a TileMap layer's name. ---- .. _class_TileMap_method_get_layer_y_sort_origin: - :ref:`int` **get_layer_y_sort_origin** **(** :ref:`int` layer **)** |const| Returns a TileMap layer's Y sort origin. ---- .. _class_TileMap_method_get_layer_z_index: - :ref:`int` **get_layer_z_index** **(** :ref:`int` layer **)** |const| Returns a TileMap layer's Z-index value. ---- .. _class_TileMap_method_get_layers_count: - :ref:`int` **get_layers_count** **(** **)** |const| ---- .. _class_TileMap_method_get_neighbor_cell: - :ref:`Vector2i` **get_neighbor_cell** **(** :ref:`Vector2i` coords, :ref:`CellNeighbor` neighbor **)** |const| Returns the neighboring cell to the one at coordinates ``coords``, identified by the ``neighbor`` direction. This method takes into account the different layouts a TileMap can take. ---- .. _class_TileMap_method_get_pattern: - :ref:`TileMapPattern` **get_pattern** **(** :ref:`int` layer, :ref:`Vector2i[]` coords_array **)** Creates a new :ref:`TileMapPattern` from the given layer and set of cells. ---- .. _class_TileMap_method_get_surrounding_tiles: - :ref:`Vector2i[]` **get_surrounding_tiles** **(** :ref:`Vector2i` coords **)** Returns the list of all neighbourings cells to the one at ``coords`` ---- .. _class_TileMap_method_get_used_cells: - :ref:`Vector2i[]` **get_used_cells** **(** :ref:`int` layer **)** |const| Returns a :ref:`Vector2` array with the positions of all cells containing a tile in the given layer. A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers is ``Vector2(-1, -1)`` and its alternative identifier is -1. ---- .. _class_TileMap_method_get_used_rect: - :ref:`Rect2` **get_used_rect** **(** **)** Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers. ---- .. _class_TileMap_method_is_layer_enabled: - :ref:`bool` **is_layer_enabled** **(** :ref:`int` layer **)** |const| Returns if a layer is enabled. ---- .. _class_TileMap_method_is_layer_y_sort_enabled: - :ref:`bool` **is_layer_y_sort_enabled** **(** :ref:`int` layer **)** |const| Returns if a layer Y-sorts its tiles. ---- .. _class_TileMap_method_map_pattern: - :ref:`Vector2i` **map_pattern** **(** :ref:`Vector2i` position_in_tilemap, :ref:`Vector2i` coords_in_pattern, :ref:`TileMapPattern` pattern **)** Returns for the given coordinate ``coords_in_pattern`` in a :ref:`TileMapPattern` the corresponding cell coordinates if the pattern was pasted at the ``position_in_tilemap`` coordinates (see :ref:`set_pattern`). This mapping is required as in half-offset tile shapes, the mapping might not work by calculating ``position_in_tile_map + coords_in_pattern`` ---- .. _class_TileMap_method_map_to_world: - :ref:`Vector2` **map_to_world** **(** :ref:`Vector2i` map_position **)** |const| Returns a local position of the center of the cell at the given tilemap (grid-based) coordinates. \ **Note:** This doesn't correspond to the visual position of the tile, i.e. it ignores the :ref:`TileData.texture_offset` property of individual tiles. ---- .. _class_TileMap_method_move_layer: - void **move_layer** **(** :ref:`int` layer, :ref:`int` to_position **)** Moves the layer at index ``layer_index`` to the given position ``to_position`` in the array. ---- .. _class_TileMap_method_remove_layer: - void **remove_layer** **(** :ref:`int` layer **)** Removes the layer at index ``layer``. ---- .. _class_TileMap_method_set_cell: - void **set_cell** **(** :ref:`int` layer, :ref:`Vector2i` coords, :ref:`int` source_id=-1, :ref:`Vector2i` atlas_coords=Vector2i(-1, -1), :ref:`int` alternative_tile=0 **)** Sets the tile indentifiers for the cell on layer ``layer`` at coordinates ``coords``. Each tile of the :ref:`TileSet` is identified using three parts: - The source identifier ``source_id`` identifies a :ref:`TileSetSource` identifier. See :ref:`TileSet.set_source_id`, - The atlas coordinates identifier ``atlas_coords`` identifies a tile coordinates in the atlas (if the source is a :ref:`TileSetAtlasSource`. For :ref:`TileSetScenesCollectionSource` it should be 0), - The alternative tile identifier ``alternative_tile`` identifies a tile alternative the source is a :ref:`TileSetAtlasSource`, and the scene for a :ref:`TileSetScenesCollectionSource`. ---- .. _class_TileMap_method_set_cells_from_surrounding_terrains: - void **set_cells_from_surrounding_terrains** **(** :ref:`int` layer, :ref:`Vector2i[]` cells, :ref:`int` terrain_set, :ref:`bool` ignore_empty_terrains=true **)** Updates all the cells in the ``cells`` coordinates array and replace them by tiles that matches the surrounding cells terrains. Only cells form the given ``terrain_set`` are considered. If ``ignore_empty_terrains`` is true, zones with no terrain defined are ignored to select the tiles. ---- .. _class_TileMap_method_set_layer_enabled: - void **set_layer_enabled** **(** :ref:`int` layer, :ref:`bool` enabled **)** Enables or disables the layer ``layer``. A disabled layer is not processed at all (no rendering, no physics, etc...). ---- .. _class_TileMap_method_set_layer_modulate: - void **set_layer_modulate** **(** :ref:`int` layer, :ref:`Color` enabled **)** Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate. ---- .. _class_TileMap_method_set_layer_name: - void **set_layer_name** **(** :ref:`int` layer, :ref:`String` name **)** Sets a layer's name. This is mostly useful in the editor. ---- .. _class_TileMap_method_set_layer_y_sort_enabled: - void **set_layer_y_sort_enabled** **(** :ref:`int` layer, :ref:`bool` y_sort_enabled **)** Enables or disables a layer's Y-sorting. If a layer is Y-sorted, the layer will behave as a CanvasItem node where each of its tile gets Y-sorted. Y-sorted layers should usually be on different Z-index values than not Y-sorted layers, otherwise, each of those layer will be Y-sorted as whole with the Y-sorted one. This is usually an undesired behvaior. ---- .. _class_TileMap_method_set_layer_y_sort_origin: - void **set_layer_y_sort_origin** **(** :ref:`int` layer, :ref:`int` y_sort_origin **)** Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value. This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games. ---- .. _class_TileMap_method_set_layer_z_index: - void **set_layer_z_index** **(** :ref:`int` layer, :ref:`int` z_index **)** Sets a layers Z-index value. This Z-index is added to each tile's Z-index value. ---- .. _class_TileMap_method_set_pattern: - void **set_pattern** **(** :ref:`int` layer, :ref:`Vector2i` position, :ref:`TileMapPattern` pattern **)** Paste the given :ref:`TileMapPattern` at the given ``position`` and ``layer`` in the tile map. ---- .. _class_TileMap_method_world_to_map: - :ref:`Vector2i` **world_to_map** **(** :ref:`Vector2` world_position **)** |const| Returns the tilemap (grid-based) coordinates corresponding to the given local position. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`