mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
578 lines
44 KiB
ReStructuredText
578 lines
44 KiB
ReStructuredText
: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/<name>/doc_classes.
|
|
|
|
.. _class_TileMap:
|
|
|
|
TileMap
|
|
=======
|
|
|
|
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
Node for 2D tile-based maps.
|
|
|
|
Description
|
|
-----------
|
|
|
|
Node for 2D tile-based maps. Tilemaps use a :ref:`TileSet<class_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 <https://godotengine.org/asset-library/asset/120>`__
|
|
|
|
- `2D Isometric Demo <https://godotengine.org/asset-library/asset/112>`__
|
|
|
|
- `2D Hexagonal Demo <https://godotengine.org/asset-library/asset/111>`__
|
|
|
|
- `2D Navigation Astar Demo <https://godotengine.org/asset-library/asset/519>`__
|
|
|
|
- `2D Role Playing Game Demo <https://godotengine.org/asset-library/asset/520>`__
|
|
|
|
- `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/113>`__
|
|
|
|
Properties
|
|
----------
|
|
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`int<class_int>` | :ref:`cell_quadrant_size<class_TileMap_property_cell_quadrant_size>` | ``16`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`bool<class_bool>` | :ref:`collision_animatable<class_TileMap_property_collision_animatable>` | ``false`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`collision_visibility_mode<class_TileMap_property_collision_visibility_mode>` | ``0`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`navigation_visibility_mode<class_TileMap_property_navigation_visibility_mode>` | ``0`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` | |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`_tile_data_runtime_update<class_TileMap_method__tile_data_runtime_update>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`TileData<class_TileData>` tile_data **)** |virtual| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`_use_tile_data_runtime_update<class_TileMap_method__use_tile_data_runtime_update>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords **)** |virtual| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`add_layer<class_TileMap_method_add_layer>` **(** :ref:`int<class_int>` to_position **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`clear<class_TileMap_method_clear>` **(** **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`clear_layer<class_TileMap_method_clear_layer>` **(** :ref:`int<class_int>` layer **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`erase_cell<class_TileMap_method_erase_cell>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>` **(** **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`force_update<class_TileMap_method_force_update>` **(** :ref:`int<class_int>` layer=-1 **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_cell_alternative_tile<class_TileMap_method_get_cell_alternative_tile>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_cell_atlas_coords<class_TileMap_method_get_cell_atlas_coords>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_cell_source_id<class_TileMap_method_get_cell_source_id>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_coords_for_body_rid<class_TileMap_method_get_coords_for_body_rid>` **(** :ref:`RID<class_RID>` body **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`get_layer_modulate<class_TileMap_method_get_layer_modulate>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_layer_name<class_TileMap_method_get_layer_name>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_layer_y_sort_origin<class_TileMap_method_get_layer_y_sort_origin>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_layer_z_index<class_TileMap_method_get_layer_z_index>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_layers_count<class_TileMap_method_get_layers_count>` **(** **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_neighbor_cell<class_TileMap_method_get_neighbor_cell>` **(** :ref:`Vector2i<class_Vector2i>` coords, :ref:`CellNeighbor<enum_TileSet_CellNeighbor>` neighbor **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`TileMapPattern<class_TileMapPattern>` | :ref:`get_pattern<class_TileMap_method_get_pattern>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` coords_array **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_surrounding_tiles<class_TileMap_method_get_surrounding_tiles>` **(** :ref:`Vector2i<class_Vector2i>` coords **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_used_cells<class_TileMap_method_get_used_cells>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>` **(** **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_layer_enabled<class_TileMap_method_is_layer_enabled>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_layer_y_sort_enabled<class_TileMap_method_is_layer_y_sort_enabled>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`map_pattern<class_TileMap_method_map_pattern>` **(** :ref:`Vector2i<class_Vector2i>` position_in_tilemap, :ref:`Vector2i<class_Vector2i>` coords_in_pattern, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`map_to_world<class_TileMap_method_map_to_world>` **(** :ref:`Vector2i<class_Vector2i>` map_position **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`move_layer<class_TileMap_method_move_layer>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` to_position **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`remove_layer<class_TileMap_method_remove_layer>` **(** :ref:`int<class_int>` layer **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_cell<class_TileMap_method_set_cell>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=0 **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_cells_from_surrounding_terrains<class_TileMap_method_set_cells_from_surrounding_terrains>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` cells, :ref:`int<class_int>` terrain_set, :ref:`bool<class_bool>` ignore_empty_terrains=true **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_enabled<class_TileMap_method_set_layer_enabled>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_modulate<class_TileMap_method_set_layer_modulate>` **(** :ref:`int<class_int>` layer, :ref:`Color<class_Color>` enabled **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_name<class_TileMap_method_set_layer_name>` **(** :ref:`int<class_int>` layer, :ref:`String<class_String>` name **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_y_sort_enabled<class_TileMap_method_set_layer_y_sort_enabled>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` y_sort_enabled **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_y_sort_origin<class_TileMap_method_set_layer_y_sort_origin>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` y_sort_origin **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_z_index<class_TileMap_method_set_layer_z_index>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` z_index **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_pattern<class_TileMap_method_set_pattern>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` position, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)** |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`world_to_map<class_TileMap_method_world_to_map>` **(** :ref:`Vector2<class_Vector2>` world_position **)** |const| |
|
|
+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_TileMap_signal_changed:
|
|
|
|
- **changed** **(** **)**
|
|
|
|
Emitted when the :ref:`TileSet<class_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<class_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<class_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<enum_TileMap_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<enum_TileMap_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<class_TileSet>` **tile_set**
|
|
|
|
+----------+--------------------+
|
|
| *Setter* | set_tileset(value) |
|
|
+----------+--------------------+
|
|
| *Getter* | get_tileset() |
|
|
+----------+--------------------+
|
|
|
|
The assigned :ref:`TileSet<class_TileSet>`.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_TileMap_method__tile_data_runtime_update:
|
|
|
|
- void **_tile_data_runtime_update** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`TileData<class_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<class_TileMap_method__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<class_TileMap_method_force_update>` to trigger a TileMap update.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method__use_tile_data_runtime_update:
|
|
|
|
- :ref:`bool<class_bool>` **_use_tile_data_runtime_update** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_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<class_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<class_int>` layer **)**
|
|
|
|
Clears all cells on the given layer.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_erase_cell:
|
|
|
|
- void **erase_cell** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_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<class_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<class_TileMap_method__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<class_int>` **get_cell_alternative_tile** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_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<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_cell_atlas_coords:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **get_cell_atlas_coords** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_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<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_cell_source_id:
|
|
|
|
- :ref:`int<class_int>` **get_cell_source_id** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_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<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_coords_for_body_rid:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **get_coords_for_body_rid** **(** :ref:`RID<class_RID>` body **)**
|
|
|
|
Returns the coordinates of the tile for given physics body RID. Such RID can be retrieved from :ref:`KinematicCollision2D.get_collider_rid<class_KinematicCollision2D_method_get_collider_rid>`, when colliding with a tile.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_modulate:
|
|
|
|
- :ref:`Color<class_Color>` **get_layer_modulate** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's modulate.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_name:
|
|
|
|
- :ref:`String<class_String>` **get_layer_name** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's name.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_y_sort_origin:
|
|
|
|
- :ref:`int<class_int>` **get_layer_y_sort_origin** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's Y sort origin.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_z_index:
|
|
|
|
- :ref:`int<class_int>` **get_layer_z_index** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's Z-index value.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layers_count:
|
|
|
|
- :ref:`int<class_int>` **get_layers_count** **(** **)** |const|
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_neighbor_cell:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **get_neighbor_cell** **(** :ref:`Vector2i<class_Vector2i>` coords, :ref:`CellNeighbor<enum_TileSet_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<class_TileMapPattern>` **get_pattern** **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` coords_array **)**
|
|
|
|
Creates a new :ref:`TileMapPattern<class_TileMapPattern>` from the given layer and set of cells.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_surrounding_tiles:
|
|
|
|
- :ref:`Vector2i[]<class_Vector2i>` **get_surrounding_tiles** **(** :ref:`Vector2i<class_Vector2i>` coords **)**
|
|
|
|
Returns the list of all neighbourings cells to the one at ``coords``
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_used_cells:
|
|
|
|
- :ref:`Vector2i[]<class_Vector2i>` **get_used_cells** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a :ref:`Vector2<class_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<class_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<class_bool>` **is_layer_enabled** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns if a layer is enabled.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_is_layer_y_sort_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_layer_y_sort_enabled** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns if a layer Y-sorts its tiles.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_map_pattern:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **map_pattern** **(** :ref:`Vector2i<class_Vector2i>` position_in_tilemap, :ref:`Vector2i<class_Vector2i>` coords_in_pattern, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)**
|
|
|
|
Returns for the given coordinate ``coords_in_pattern`` in a :ref:`TileMapPattern<class_TileMapPattern>` the corresponding cell coordinates if the pattern was pasted at the ``position_in_tilemap`` coordinates (see :ref:`set_pattern<class_TileMap_method_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<class_Vector2>` **map_to_world** **(** :ref:`Vector2i<class_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<class_TileData_property_texture_offset>` property of individual tiles.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_move_layer:
|
|
|
|
- void **move_layer** **(** :ref:`int<class_int>` layer, :ref:`int<class_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<class_int>` layer **)**
|
|
|
|
Removes the layer at index ``layer``.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_cell:
|
|
|
|
- void **set_cell** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=0 **)**
|
|
|
|
Sets the tile indentifiers for the cell on layer ``layer`` at coordinates ``coords``. Each tile of the :ref:`TileSet<class_TileSet>` is identified using three parts:
|
|
|
|
- The source identifier ``source_id`` identifies a :ref:`TileSetSource<class_TileSetSource>` identifier. See :ref:`TileSet.set_source_id<class_TileSet_method_set_source_id>`,
|
|
|
|
- The atlas coordinates identifier ``atlas_coords`` identifies a tile coordinates in the atlas (if the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`. For :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>` it should be 0),
|
|
|
|
- The alternative tile identifier ``alternative_tile`` identifies a tile alternative the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`, and the scene for a :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_cells_from_surrounding_terrains:
|
|
|
|
- void **set_cells_from_surrounding_terrains** **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` cells, :ref:`int<class_int>` terrain_set, :ref:`bool<class_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<class_int>` layer, :ref:`bool<class_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<class_int>` layer, :ref:`Color<class_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<class_int>` layer, :ref:`String<class_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<class_int>` layer, :ref:`bool<class_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<class_int>` layer, :ref:`int<class_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<class_int>` layer, :ref:`int<class_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<class_int>` layer, :ref:`Vector2i<class_Vector2i>` position, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)**
|
|
|
|
Paste the given :ref:`TileMapPattern<class_TileMapPattern>` at the given ``position`` and ``layer`` in the tile map.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_world_to_map:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **world_to_map** **(** :ref:`Vector2<class_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.)`
|