class_tilemap.rst 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. :github_url: hide
  2. .. meta::
  3. :keywords: gridmap
  4. .. DO NOT EDIT THIS FILE!!!
  5. .. Generated automatically from Godot engine sources.
  6. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  7. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TileMap.xml.
  8. .. _class_TileMap:
  9. TileMap
  10. =======
  11. **Deprecated:** Use multiple :ref:`TileMapLayer<class_TileMapLayer>` nodes instead. To convert a TileMap to a set of TileMapLayer nodes, open the TileMap bottom panel with the node selected, click the toolbox icon in the top-right corner and choose 'Extract TileMap layers as individual TileMapLayer nodes'.
  12. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  13. Node for 2D tile-based maps.
  14. .. rst-class:: classref-introduction-group
  15. Description
  16. -----------
  17. 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.
  18. For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>` may be initialized after their parent. This is only queued when inside the scene tree.
  19. To force an update earlier on, call :ref:`update_internals<class_TileMap_method_update_internals>`.
  20. .. rst-class:: classref-introduction-group
  21. Tutorials
  22. ---------
  23. - :doc:`Using Tilemaps <../tutorials/2d/using_tilemaps>`
  24. - `2D Platformer Demo <https://godotengine.org/asset-library/asset/2727>`__
  25. - `2D Isometric Demo <https://godotengine.org/asset-library/asset/2718>`__
  26. - `2D Hexagonal Demo <https://godotengine.org/asset-library/asset/2717>`__
  27. - `2D Grid-based Navigation with AStarGrid2D Demo <https://godotengine.org/asset-library/asset/2723>`__
  28. - `2D Role Playing Game (RPG) Demo <https://godotengine.org/asset-library/asset/2729>`__
  29. - `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/2719>`__
  30. .. rst-class:: classref-reftable-group
  31. Properties
  32. ----------
  33. .. table::
  34. :widths: auto
  35. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`collision_animatable<class_TileMap_property_collision_animatable>` | ``false`` |
  37. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  38. | :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`collision_visibility_mode<class_TileMap_property_collision_visibility_mode>` | ``0`` |
  39. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  40. | :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`navigation_visibility_mode<class_TileMap_property_navigation_visibility_mode>` | ``0`` |
  41. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  42. | :ref:`int<class_int>` | :ref:`rendering_quadrant_size<class_TileMap_property_rendering_quadrant_size>` | ``16`` |
  43. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  44. | :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` | |
  45. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  46. .. rst-class:: classref-reftable-group
  47. Methods
  48. -------
  49. .. table::
  50. :widths: auto
  51. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | |void| | :ref:`_tile_data_runtime_update<class_TileMap_private_method__tile_data_runtime_update>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, tile_data\: :ref:`TileData<class_TileData>`\ ) |virtual| |
  53. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`_use_tile_data_runtime_update<class_TileMap_private_method__use_tile_data_runtime_update>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`\ ) |virtual| |
  55. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | |void| | :ref:`add_layer<class_TileMap_method_add_layer>`\ (\ to_position\: :ref:`int<class_int>`\ ) |
  57. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | |void| | :ref:`clear<class_TileMap_method_clear>`\ (\ ) |
  59. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | |void| | :ref:`clear_layer<class_TileMap_method_clear_layer>`\ (\ layer\: :ref:`int<class_int>`\ ) |
  61. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | |void| | :ref:`erase_cell<class_TileMap_method_erase_cell>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`\ ) |
  63. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | |void| | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>`\ (\ ) |
  65. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | |void| | :ref:`force_update<class_TileMap_method_force_update>`\ (\ layer\: :ref:`int<class_int>` = -1\ ) |
  67. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`get_cell_alternative_tile<class_TileMap_method_get_cell_alternative_tile>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  69. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_cell_atlas_coords<class_TileMap_method_get_cell_atlas_coords>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  71. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`int<class_int>` | :ref:`get_cell_source_id<class_TileMap_method_get_cell_source_id>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  73. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`TileData<class_TileData>` | :ref:`get_cell_tile_data<class_TileMap_method_get_cell_tile_data>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  75. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_coords_for_body_rid<class_TileMap_method_get_coords_for_body_rid>`\ (\ body\: :ref:`RID<class_RID>`\ ) |
  77. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`int<class_int>` | :ref:`get_layer_for_body_rid<class_TileMap_method_get_layer_for_body_rid>`\ (\ body\: :ref:`RID<class_RID>`\ ) |
  79. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Color<class_Color>` | :ref:`get_layer_modulate<class_TileMap_method_get_layer_modulate>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  81. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`String<class_String>` | :ref:`get_layer_name<class_TileMap_method_get_layer_name>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  83. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`RID<class_RID>` | :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  85. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`int<class_int>` | :ref:`get_layer_y_sort_origin<class_TileMap_method_get_layer_y_sort_origin>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  87. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`int<class_int>` | :ref:`get_layer_z_index<class_TileMap_method_get_layer_z_index>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  89. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`int<class_int>` | :ref:`get_layers_count<class_TileMap_method_get_layers_count>`\ (\ ) |const| |
  91. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_TileMap_method_get_navigation_map>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  93. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_neighbor_cell<class_TileMap_method_get_neighbor_cell>`\ (\ coords\: :ref:`Vector2i<class_Vector2i>`, neighbor\: :ref:`CellNeighbor<enum_TileSet_CellNeighbor>`\ ) |const| |
  95. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`TileMapPattern<class_TileMapPattern>` | :ref:`get_pattern<class_TileMap_method_get_pattern>`\ (\ layer\: :ref:`int<class_int>`, coords_array\: :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\]\ ) |
  97. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] | :ref:`get_surrounding_cells<class_TileMap_method_get_surrounding_cells>`\ (\ coords\: :ref:`Vector2i<class_Vector2i>`\ ) |
  99. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] | :ref:`get_used_cells<class_TileMap_method_get_used_cells>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  101. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] | :ref:`get_used_cells_by_id<class_TileMap_method_get_used_cells_by_id>`\ (\ layer\: :ref:`int<class_int>`, source_id\: :ref:`int<class_int>` = -1, atlas_coords\: :ref:`Vector2i<class_Vector2i>` = Vector2i(-1, -1), alternative_tile\: :ref:`int<class_int>` = -1\ ) |const| |
  103. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Rect2i<class_Rect2i>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>`\ (\ ) |const| |
  105. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`bool<class_bool>` | :ref:`is_cell_flipped_h<class_TileMap_method_is_cell_flipped_h>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  107. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`bool<class_bool>` | :ref:`is_cell_flipped_v<class_TileMap_method_is_cell_flipped_v>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  109. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`bool<class_bool>` | :ref:`is_cell_transposed<class_TileMap_method_is_cell_transposed>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| |
  111. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`bool<class_bool>` | :ref:`is_layer_enabled<class_TileMap_method_is_layer_enabled>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  113. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`bool<class_bool>` | :ref:`is_layer_navigation_enabled<class_TileMap_method_is_layer_navigation_enabled>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  115. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`bool<class_bool>` | :ref:`is_layer_y_sort_enabled<class_TileMap_method_is_layer_y_sort_enabled>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  117. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`Vector2i<class_Vector2i>` | :ref:`local_to_map<class_TileMap_method_local_to_map>`\ (\ local_position\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  119. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`Vector2i<class_Vector2i>` | :ref:`map_pattern<class_TileMap_method_map_pattern>`\ (\ position_in_tilemap\: :ref:`Vector2i<class_Vector2i>`, coords_in_pattern\: :ref:`Vector2i<class_Vector2i>`, pattern\: :ref:`TileMapPattern<class_TileMapPattern>`\ ) |
  121. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`Vector2<class_Vector2>` | :ref:`map_to_local<class_TileMap_method_map_to_local>`\ (\ map_position\: :ref:`Vector2i<class_Vector2i>`\ ) |const| |
  123. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | |void| | :ref:`move_layer<class_TileMap_method_move_layer>`\ (\ layer\: :ref:`int<class_int>`, to_position\: :ref:`int<class_int>`\ ) |
  125. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | |void| | :ref:`notify_runtime_tile_data_update<class_TileMap_method_notify_runtime_tile_data_update>`\ (\ layer\: :ref:`int<class_int>` = -1\ ) |
  127. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | |void| | :ref:`remove_layer<class_TileMap_method_remove_layer>`\ (\ layer\: :ref:`int<class_int>`\ ) |
  129. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | |void| | :ref:`set_cell<class_TileMap_method_set_cell>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, source_id\: :ref:`int<class_int>` = -1, atlas_coords\: :ref:`Vector2i<class_Vector2i>` = Vector2i(-1, -1), alternative_tile\: :ref:`int<class_int>` = 0\ ) |
  131. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | |void| | :ref:`set_cells_terrain_connect<class_TileMap_method_set_cells_terrain_connect>`\ (\ layer\: :ref:`int<class_int>`, cells\: :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\], terrain_set\: :ref:`int<class_int>`, terrain\: :ref:`int<class_int>`, ignore_empty_terrains\: :ref:`bool<class_bool>` = true\ ) |
  133. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | |void| | :ref:`set_cells_terrain_path<class_TileMap_method_set_cells_terrain_path>`\ (\ layer\: :ref:`int<class_int>`, path\: :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\], terrain_set\: :ref:`int<class_int>`, terrain\: :ref:`int<class_int>`, ignore_empty_terrains\: :ref:`bool<class_bool>` = true\ ) |
  135. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | |void| | :ref:`set_layer_enabled<class_TileMap_method_set_layer_enabled>`\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) |
  137. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | |void| | :ref:`set_layer_modulate<class_TileMap_method_set_layer_modulate>`\ (\ layer\: :ref:`int<class_int>`, modulate\: :ref:`Color<class_Color>`\ ) |
  139. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | |void| | :ref:`set_layer_name<class_TileMap_method_set_layer_name>`\ (\ layer\: :ref:`int<class_int>`, name\: :ref:`String<class_String>`\ ) |
  141. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | |void| | :ref:`set_layer_navigation_enabled<class_TileMap_method_set_layer_navigation_enabled>`\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) |
  143. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | |void| | :ref:`set_layer_navigation_map<class_TileMap_method_set_layer_navigation_map>`\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) |
  145. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | |void| | :ref:`set_layer_y_sort_enabled<class_TileMap_method_set_layer_y_sort_enabled>`\ (\ layer\: :ref:`int<class_int>`, y_sort_enabled\: :ref:`bool<class_bool>`\ ) |
  147. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | |void| | :ref:`set_layer_y_sort_origin<class_TileMap_method_set_layer_y_sort_origin>`\ (\ layer\: :ref:`int<class_int>`, y_sort_origin\: :ref:`int<class_int>`\ ) |
  149. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | |void| | :ref:`set_layer_z_index<class_TileMap_method_set_layer_z_index>`\ (\ layer\: :ref:`int<class_int>`, z_index\: :ref:`int<class_int>`\ ) |
  151. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | |void| | :ref:`set_navigation_map<class_TileMap_method_set_navigation_map>`\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) |
  153. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | |void| | :ref:`set_pattern<class_TileMap_method_set_pattern>`\ (\ layer\: :ref:`int<class_int>`, position\: :ref:`Vector2i<class_Vector2i>`, pattern\: :ref:`TileMapPattern<class_TileMapPattern>`\ ) |
  155. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | |void| | :ref:`update_internals<class_TileMap_method_update_internals>`\ (\ ) |
  157. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. .. rst-class:: classref-section-separator
  159. ----
  160. .. rst-class:: classref-descriptions-group
  161. Signals
  162. -------
  163. .. _class_TileMap_signal_changed:
  164. .. rst-class:: classref-signal
  165. **changed**\ (\ ) :ref:`🔗<class_TileMap_signal_changed>`
  166. Emitted when the :ref:`TileSet<class_TileSet>` of this TileMap changes.
  167. .. rst-class:: classref-section-separator
  168. ----
  169. .. rst-class:: classref-descriptions-group
  170. Enumerations
  171. ------------
  172. .. _enum_TileMap_VisibilityMode:
  173. .. rst-class:: classref-enumeration
  174. enum **VisibilityMode**: :ref:`🔗<enum_TileMap_VisibilityMode>`
  175. .. _class_TileMap_constant_VISIBILITY_MODE_DEFAULT:
  176. .. rst-class:: classref-enumeration-constant
  177. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_DEFAULT** = ``0``
  178. Use the debug settings to determine visibility.
  179. .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_HIDE:
  180. .. rst-class:: classref-enumeration-constant
  181. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_FORCE_HIDE** = ``2``
  182. Always hide.
  183. .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_SHOW:
  184. .. rst-class:: classref-enumeration-constant
  185. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_FORCE_SHOW** = ``1``
  186. Always show.
  187. .. rst-class:: classref-section-separator
  188. ----
  189. .. rst-class:: classref-descriptions-group
  190. Property Descriptions
  191. ---------------------
  192. .. _class_TileMap_property_collision_animatable:
  193. .. rst-class:: classref-property
  194. :ref:`bool<class_bool>` **collision_animatable** = ``false`` :ref:`🔗<class_TileMap_property_collision_animatable>`
  195. .. rst-class:: classref-property-setget
  196. - |void| **set_collision_animatable**\ (\ value\: :ref:`bool<class_bool>`\ )
  197. - :ref:`bool<class_bool>` **is_collision_animatable**\ (\ )
  198. 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.
  199. \ **Note:** Enabling :ref:`collision_animatable<class_TileMap_property_collision_animatable>` may have a small performance impact, only do it if the TileMap is moving and has colliding tiles.
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_TileMap_property_collision_visibility_mode:
  203. .. rst-class:: classref-property
  204. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **collision_visibility_mode** = ``0`` :ref:`🔗<class_TileMap_property_collision_visibility_mode>`
  205. .. rst-class:: classref-property-setget
  206. - |void| **set_collision_visibility_mode**\ (\ value\: :ref:`VisibilityMode<enum_TileMap_VisibilityMode>`\ )
  207. - :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **get_collision_visibility_mode**\ (\ )
  208. Show or hide the TileMap's collision shapes. If set to :ref:`VISIBILITY_MODE_DEFAULT<class_TileMap_constant_VISIBILITY_MODE_DEFAULT>`, this depends on the show collision debug settings.
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_TileMap_property_navigation_visibility_mode:
  212. .. rst-class:: classref-property
  213. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **navigation_visibility_mode** = ``0`` :ref:`🔗<class_TileMap_property_navigation_visibility_mode>`
  214. .. rst-class:: classref-property-setget
  215. - |void| **set_navigation_visibility_mode**\ (\ value\: :ref:`VisibilityMode<enum_TileMap_VisibilityMode>`\ )
  216. - :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **get_navigation_visibility_mode**\ (\ )
  217. Show or hide the TileMap's navigation meshes. If set to :ref:`VISIBILITY_MODE_DEFAULT<class_TileMap_constant_VISIBILITY_MODE_DEFAULT>`, this depends on the show navigation debug settings.
  218. .. rst-class:: classref-item-separator
  219. ----
  220. .. _class_TileMap_property_rendering_quadrant_size:
  221. .. rst-class:: classref-property
  222. :ref:`int<class_int>` **rendering_quadrant_size** = ``16`` :ref:`🔗<class_TileMap_property_rendering_quadrant_size>`
  223. .. rst-class:: classref-property-setget
  224. - |void| **set_rendering_quadrant_size**\ (\ value\: :ref:`int<class_int>`\ )
  225. - :ref:`int<class_int>` **get_rendering_quadrant_size**\ (\ )
  226. The TileMap's quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes. :ref:`rendering_quadrant_size<class_TileMap_property_rendering_quadrant_size>` defines the length of a square's side, in the map's coordinate system, that forms the quadrant. Thus, the default quadrant size groups together ``16 * 16 = 256`` tiles.
  227. The quadrant size does not apply on Y-sorted layers, as tiles are grouped by Y position instead in that case.
  228. \ **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.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_TileMap_property_tile_set:
  232. .. rst-class:: classref-property
  233. :ref:`TileSet<class_TileSet>` **tile_set** :ref:`🔗<class_TileMap_property_tile_set>`
  234. .. rst-class:: classref-property-setget
  235. - |void| **set_tileset**\ (\ value\: :ref:`TileSet<class_TileSet>`\ )
  236. - :ref:`TileSet<class_TileSet>` **get_tileset**\ (\ )
  237. The :ref:`TileSet<class_TileSet>` used by this **TileMap**. The textures, collisions, and additional behavior of all available tiles are stored here.
  238. .. rst-class:: classref-section-separator
  239. ----
  240. .. rst-class:: classref-descriptions-group
  241. Method Descriptions
  242. -------------------
  243. .. _class_TileMap_private_method__tile_data_runtime_update:
  244. .. rst-class:: classref-method
  245. |void| **_tile_data_runtime_update**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, tile_data\: :ref:`TileData<class_TileData>`\ ) |virtual| :ref:`🔗<class_TileMap_private_method__tile_data_runtime_update>`
  246. Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime.
  247. This method is only called if :ref:`_use_tile_data_runtime_update<class_TileMap_private_method__use_tile_data_runtime_update>` is implemented and returns ``true`` for the given tile ``coords`` and ``layer``.
  248. \ **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.
  249. \ **Note:** If the properties of ``tile_data`` object should change over time, use :ref:`notify_runtime_tile_data_update<class_TileMap_method_notify_runtime_tile_data_update>` to notify the TileMap it needs an update.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_TileMap_private_method__use_tile_data_runtime_update:
  253. .. rst-class:: classref-method
  254. :ref:`bool<class_bool>` **_use_tile_data_runtime_update**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`\ ) |virtual| :ref:`🔗<class_TileMap_private_method__use_tile_data_runtime_update>`
  255. Should return ``true`` if the tile at coordinates ``coords`` on layer ``layer`` requires a runtime update.
  256. \ **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.
  257. \ **Note:** If the result of this function should changed, use :ref:`notify_runtime_tile_data_update<class_TileMap_method_notify_runtime_tile_data_update>` to notify the TileMap it needs an update.
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _class_TileMap_method_add_layer:
  261. .. rst-class:: classref-method
  262. |void| **add_layer**\ (\ to_position\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_add_layer>`
  263. 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 ``-1`` adding the layer at the end of the array.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_TileMap_method_clear:
  267. .. rst-class:: classref-method
  268. |void| **clear**\ (\ ) :ref:`🔗<class_TileMap_method_clear>`
  269. Clears all cells.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_TileMap_method_clear_layer:
  273. .. rst-class:: classref-method
  274. |void| **clear_layer**\ (\ layer\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_clear_layer>`
  275. Clears all cells on the given layer.
  276. If ``layer`` is negative, the layers are accessed from the last one.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_TileMap_method_erase_cell:
  280. .. rst-class:: classref-method
  281. |void| **erase_cell**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`🔗<class_TileMap_method_erase_cell>`
  282. Erases the cell on layer ``layer`` at coordinates ``coords``.
  283. If ``layer`` is negative, the layers are accessed from the last one.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_TileMap_method_fix_invalid_tiles:
  287. .. rst-class:: classref-method
  288. |void| **fix_invalid_tiles**\ (\ ) :ref:`🔗<class_TileMap_method_fix_invalid_tiles>`
  289. Clears cells that do not exist in the tileset.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_TileMap_method_force_update:
  293. .. rst-class:: classref-method
  294. |void| **force_update**\ (\ layer\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_TileMap_method_force_update>`
  295. **Deprecated:** Use :ref:`notify_runtime_tile_data_update<class_TileMap_method_notify_runtime_tile_data_update>` and/or :ref:`update_internals<class_TileMap_method_update_internals>` instead.
  296. Forces the TileMap and the layer ``layer`` to update.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_TileMap_method_get_cell_alternative_tile:
  300. .. rst-class:: classref-method
  301. :ref:`int<class_int>` **get_cell_alternative_tile**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_get_cell_alternative_tile>`
  302. Returns the tile alternative ID of the cell on layer ``layer`` at ``coords``.
  303. 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>`.
  304. If ``layer`` is negative, the layers are accessed from the last one.
  305. .. rst-class:: classref-item-separator
  306. ----
  307. .. _class_TileMap_method_get_cell_atlas_coords:
  308. .. rst-class:: classref-method
  309. :ref:`Vector2i<class_Vector2i>` **get_cell_atlas_coords**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_get_cell_atlas_coords>`
  310. Returns the tile atlas coordinates ID of the cell on layer ``layer`` at coordinates ``coords``. Returns ``Vector2i(-1, -1)`` if the cell does not exist.
  311. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw atlas coordinate identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  312. If ``layer`` is negative, the layers are accessed from the last one.
  313. .. rst-class:: classref-item-separator
  314. ----
  315. .. _class_TileMap_method_get_cell_source_id:
  316. .. rst-class:: classref-method
  317. :ref:`int<class_int>` **get_cell_source_id**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_get_cell_source_id>`
  318. Returns the tile source ID of the cell on layer ``layer`` at coordinates ``coords``. Returns ``-1`` if the cell does not exist.
  319. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw source identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  320. If ``layer`` is negative, the layers are accessed from the last one.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_TileMap_method_get_cell_tile_data:
  324. .. rst-class:: classref-method
  325. :ref:`TileData<class_TileData>` **get_cell_tile_data**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_get_cell_tile_data>`
  326. Returns the :ref:`TileData<class_TileData>` object associated with the given cell, or ``null`` if the cell does not exist or is not a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`.
  327. If ``layer`` is negative, the layers are accessed from the last one.
  328. ::
  329. func get_clicked_tile_power():
  330. var clicked_cell = tile_map.local_to_map(tile_map.get_local_mouse_position())
  331. var data = tile_map.get_cell_tile_data(0, clicked_cell)
  332. if data:
  333. return data.get_custom_data("power")
  334. else:
  335. return 0
  336. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  337. .. rst-class:: classref-item-separator
  338. ----
  339. .. _class_TileMap_method_get_coords_for_body_rid:
  340. .. rst-class:: classref-method
  341. :ref:`Vector2i<class_Vector2i>` **get_coords_for_body_rid**\ (\ body\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_get_coords_for_body_rid>`
  342. 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.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_TileMap_method_get_layer_for_body_rid:
  346. .. rst-class:: classref-method
  347. :ref:`int<class_int>` **get_layer_for_body_rid**\ (\ body\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_get_layer_for_body_rid>`
  348. Returns the tilemap layer 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.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_TileMap_method_get_layer_modulate:
  352. .. rst-class:: classref-method
  353. :ref:`Color<class_Color>` **get_layer_modulate**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_modulate>`
  354. Returns a TileMap layer's modulate.
  355. If ``layer`` is negative, the layers are accessed from the last one.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_TileMap_method_get_layer_name:
  359. .. rst-class:: classref-method
  360. :ref:`String<class_String>` **get_layer_name**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_name>`
  361. Returns a TileMap layer's name.
  362. If ``layer`` is negative, the layers are accessed from the last one.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_TileMap_method_get_layer_navigation_map:
  366. .. rst-class:: classref-method
  367. :ref:`RID<class_RID>` **get_layer_navigation_map**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_navigation_map>`
  368. Returns the :ref:`RID<class_RID>` of the :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map assigned to the specified TileMap layer ``layer``.
  369. By default the TileMap uses the default :ref:`World2D<class_World2D>` navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer.
  370. In order to make :ref:`NavigationAgent2D<class_NavigationAgent2D>` switch between TileMap layer navigation maps use :ref:`NavigationAgent2D.set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>` with the navigation map received from :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`.
  371. If ``layer`` is negative, the layers are accessed from the last one.
  372. .. rst-class:: classref-item-separator
  373. ----
  374. .. _class_TileMap_method_get_layer_y_sort_origin:
  375. .. rst-class:: classref-method
  376. :ref:`int<class_int>` **get_layer_y_sort_origin**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_y_sort_origin>`
  377. Returns a TileMap layer's Y sort origin.
  378. If ``layer`` is negative, the layers are accessed from the last one.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_TileMap_method_get_layer_z_index:
  382. .. rst-class:: classref-method
  383. :ref:`int<class_int>` **get_layer_z_index**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_z_index>`
  384. Returns a TileMap layer's Z-index value.
  385. If ``layer`` is negative, the layers are accessed from the last one.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_TileMap_method_get_layers_count:
  389. .. rst-class:: classref-method
  390. :ref:`int<class_int>` **get_layers_count**\ (\ ) |const| :ref:`🔗<class_TileMap_method_get_layers_count>`
  391. Returns the number of layers in the TileMap.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _class_TileMap_method_get_navigation_map:
  395. .. rst-class:: classref-method
  396. :ref:`RID<class_RID>` **get_navigation_map**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_navigation_map>`
  397. **Deprecated:** Use :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>` instead.
  398. Returns the :ref:`RID<class_RID>` of the :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map assigned to the specified TileMap layer ``layer``.
  399. .. rst-class:: classref-item-separator
  400. ----
  401. .. _class_TileMap_method_get_neighbor_cell:
  402. .. rst-class:: classref-method
  403. :ref:`Vector2i<class_Vector2i>` **get_neighbor_cell**\ (\ coords\: :ref:`Vector2i<class_Vector2i>`, neighbor\: :ref:`CellNeighbor<enum_TileSet_CellNeighbor>`\ ) |const| :ref:`🔗<class_TileMap_method_get_neighbor_cell>`
  404. 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.
  405. .. rst-class:: classref-item-separator
  406. ----
  407. .. _class_TileMap_method_get_pattern:
  408. .. rst-class:: classref-method
  409. :ref:`TileMapPattern<class_TileMapPattern>` **get_pattern**\ (\ layer\: :ref:`int<class_int>`, coords_array\: :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\]\ ) :ref:`🔗<class_TileMap_method_get_pattern>`
  410. Creates a new :ref:`TileMapPattern<class_TileMapPattern>` from the given layer and set of cells.
  411. If ``layer`` is negative, the layers are accessed from the last one.
  412. .. rst-class:: classref-item-separator
  413. ----
  414. .. _class_TileMap_method_get_surrounding_cells:
  415. .. rst-class:: classref-method
  416. :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] **get_surrounding_cells**\ (\ coords\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`🔗<class_TileMap_method_get_surrounding_cells>`
  417. Returns the list of all neighbourings cells to the one at ``coords``.
  418. .. rst-class:: classref-item-separator
  419. ----
  420. .. _class_TileMap_method_get_used_cells:
  421. .. rst-class:: classref-method
  422. :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] **get_used_cells**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_used_cells>`
  423. Returns a :ref:`Vector2i<class_Vector2i>` 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.
  424. If ``layer`` is negative, the layers are accessed from the last one.
  425. .. rst-class:: classref-item-separator
  426. ----
  427. .. _class_TileMap_method_get_used_cells_by_id:
  428. .. rst-class:: classref-method
  429. :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] **get_used_cells_by_id**\ (\ layer\: :ref:`int<class_int>`, source_id\: :ref:`int<class_int>` = -1, atlas_coords\: :ref:`Vector2i<class_Vector2i>` = Vector2i(-1, -1), alternative_tile\: :ref:`int<class_int>` = -1\ ) |const| :ref:`🔗<class_TileMap_method_get_used_cells_by_id>`
  430. Returns a :ref:`Vector2i<class_Vector2i>` array with the positions of all cells containing a tile in the given layer. Tiles may be filtered according to their source (``source_id``), their atlas coordinates (``atlas_coords``) or alternative id (``alternative_tile``).
  431. If a parameter has its value set to the default one, this parameter is not used to filter a cell. Thus, if all parameters have their respective default value, this method returns the same result as :ref:`get_used_cells<class_TileMap_method_get_used_cells>`.
  432. 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.
  433. If ``layer`` is negative, the layers are accessed from the last one.
  434. .. rst-class:: classref-item-separator
  435. ----
  436. .. _class_TileMap_method_get_used_rect:
  437. .. rst-class:: classref-method
  438. :ref:`Rect2i<class_Rect2i>` **get_used_rect**\ (\ ) |const| :ref:`🔗<class_TileMap_method_get_used_rect>`
  439. Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers.
  440. .. rst-class:: classref-item-separator
  441. ----
  442. .. _class_TileMap_method_is_cell_flipped_h:
  443. .. rst-class:: classref-method
  444. :ref:`bool<class_bool>` **is_cell_flipped_h**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_is_cell_flipped_h>`
  445. Returns ``true`` if the cell on layer ``layer`` at coordinates ``coords`` is flipped horizontally. The result is valid only for atlas sources.
  446. .. rst-class:: classref-item-separator
  447. ----
  448. .. _class_TileMap_method_is_cell_flipped_v:
  449. .. rst-class:: classref-method
  450. :ref:`bool<class_bool>` **is_cell_flipped_v**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_is_cell_flipped_v>`
  451. Returns ``true`` if the cell on layer ``layer`` at coordinates ``coords`` is flipped vertically. The result is valid only for atlas sources.
  452. .. rst-class:: classref-item-separator
  453. ----
  454. .. _class_TileMap_method_is_cell_transposed:
  455. .. rst-class:: classref-method
  456. :ref:`bool<class_bool>` **is_cell_transposed**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, use_proxies\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_TileMap_method_is_cell_transposed>`
  457. Returns ``true`` if the cell on layer ``layer`` at coordinates ``coords`` is transposed. The result is valid only for atlas sources.
  458. .. rst-class:: classref-item-separator
  459. ----
  460. .. _class_TileMap_method_is_layer_enabled:
  461. .. rst-class:: classref-method
  462. :ref:`bool<class_bool>` **is_layer_enabled**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_is_layer_enabled>`
  463. Returns if a layer is enabled.
  464. If ``layer`` is negative, the layers are accessed from the last one.
  465. .. rst-class:: classref-item-separator
  466. ----
  467. .. _class_TileMap_method_is_layer_navigation_enabled:
  468. .. rst-class:: classref-method
  469. :ref:`bool<class_bool>` **is_layer_navigation_enabled**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_is_layer_navigation_enabled>`
  470. Returns if a layer's built-in navigation regions generation is enabled.
  471. .. rst-class:: classref-item-separator
  472. ----
  473. .. _class_TileMap_method_is_layer_y_sort_enabled:
  474. .. rst-class:: classref-method
  475. :ref:`bool<class_bool>` **is_layer_y_sort_enabled**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_is_layer_y_sort_enabled>`
  476. Returns if a layer Y-sorts its tiles.
  477. If ``layer`` is negative, the layers are accessed from the last one.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_TileMap_method_local_to_map:
  481. .. rst-class:: classref-method
  482. :ref:`Vector2i<class_Vector2i>` **local_to_map**\ (\ local_position\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_TileMap_method_local_to_map>`
  483. Returns the map coordinates of the cell containing the given ``local_position``. If ``local_position`` is in global coordinates, consider using :ref:`Node2D.to_local<class_Node2D_method_to_local>` before passing it to this method. See also :ref:`map_to_local<class_TileMap_method_map_to_local>`.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_TileMap_method_map_pattern:
  487. .. rst-class:: classref-method
  488. :ref:`Vector2i<class_Vector2i>` **map_pattern**\ (\ position_in_tilemap\: :ref:`Vector2i<class_Vector2i>`, coords_in_pattern\: :ref:`Vector2i<class_Vector2i>`, pattern\: :ref:`TileMapPattern<class_TileMapPattern>`\ ) :ref:`🔗<class_TileMap_method_map_pattern>`
  489. 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``.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_TileMap_method_map_to_local:
  493. .. rst-class:: classref-method
  494. :ref:`Vector2<class_Vector2>` **map_to_local**\ (\ map_position\: :ref:`Vector2i<class_Vector2i>`\ ) |const| :ref:`🔗<class_TileMap_method_map_to_local>`
  495. Returns the centered position of a cell in the TileMap's local coordinate space. To convert the returned value into global coordinates, use :ref:`Node2D.to_global<class_Node2D_method_to_global>`. See also :ref:`local_to_map<class_TileMap_method_local_to_map>`.
  496. \ **Note:** This may not correspond to the visual position of the tile, i.e. it ignores the :ref:`TileData.texture_origin<class_TileData_property_texture_origin>` property of individual tiles.
  497. .. rst-class:: classref-item-separator
  498. ----
  499. .. _class_TileMap_method_move_layer:
  500. .. rst-class:: classref-method
  501. |void| **move_layer**\ (\ layer\: :ref:`int<class_int>`, to_position\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_move_layer>`
  502. Moves the layer at index ``layer`` to the given position ``to_position`` in the array.
  503. .. rst-class:: classref-item-separator
  504. ----
  505. .. _class_TileMap_method_notify_runtime_tile_data_update:
  506. .. rst-class:: classref-method
  507. |void| **notify_runtime_tile_data_update**\ (\ layer\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_TileMap_method_notify_runtime_tile_data_update>`
  508. Notifies the TileMap node that calls to :ref:`_use_tile_data_runtime_update<class_TileMap_private_method__use_tile_data_runtime_update>` or :ref:`_tile_data_runtime_update<class_TileMap_private_method__tile_data_runtime_update>` will lead to different results. This will thus trigger a TileMap update.
  509. If ``layer`` is provided, only notifies changes for the given layer. Providing the ``layer`` argument (when applicable) is usually preferred for performance reasons.
  510. \ **Warning:** Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of calls to this function to avoid unnecessary update.
  511. \ **Note:** This does not trigger a direct update of the TileMap, the update will be done at the end of the frame as usual (unless you call :ref:`update_internals<class_TileMap_method_update_internals>`).
  512. .. rst-class:: classref-item-separator
  513. ----
  514. .. _class_TileMap_method_remove_layer:
  515. .. rst-class:: classref-method
  516. |void| **remove_layer**\ (\ layer\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_remove_layer>`
  517. Removes the layer at index ``layer``.
  518. .. rst-class:: classref-item-separator
  519. ----
  520. .. _class_TileMap_method_set_cell:
  521. .. rst-class:: classref-method
  522. |void| **set_cell**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`, source_id\: :ref:`int<class_int>` = -1, atlas_coords\: :ref:`Vector2i<class_Vector2i>` = Vector2i(-1, -1), alternative_tile\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_TileMap_method_set_cell>`
  523. Sets the tile identifiers for the cell on layer ``layer`` at coordinates ``coords``. Each tile of the :ref:`TileSet<class_TileSet>` is identified using three parts:
  524. - The source identifier ``source_id`` identifies a :ref:`TileSetSource<class_TileSetSource>` identifier. See :ref:`TileSet.set_source_id<class_TileSet_method_set_source_id>`,
  525. - 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 always be ``Vector2i(0, 0)``),
  526. - The alternative tile identifier ``alternative_tile`` identifies a tile alternative in the atlas (if the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`), and the scene for a :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>`.
  527. If ``source_id`` is set to ``-1``, ``atlas_coords`` to ``Vector2i(-1, -1)`` or ``alternative_tile`` to ``-1``, the cell will be erased. An erased cell gets **all** its identifiers automatically set to their respective invalid values, namely ``-1``, ``Vector2i(-1, -1)`` and ``-1``.
  528. If ``layer`` is negative, the layers are accessed from the last one.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_TileMap_method_set_cells_terrain_connect:
  532. .. rst-class:: classref-method
  533. |void| **set_cells_terrain_connect**\ (\ layer\: :ref:`int<class_int>`, cells\: :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\], terrain_set\: :ref:`int<class_int>`, terrain\: :ref:`int<class_int>`, ignore_empty_terrains\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_TileMap_method_set_cells_terrain_connect>`
  534. Update all the cells in the ``cells`` coordinates array so that they use the given ``terrain`` for the given ``terrain_set``. If an updated cell has the same terrain as one of its neighboring cells, this function tries to join the two. This function might update neighboring tiles if needed to create correct terrain transitions.
  535. If ``ignore_empty_terrains`` is ``true``, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
  536. If ``layer`` is negative, the layers are accessed from the last one.
  537. \ **Note:** To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
  538. .. rst-class:: classref-item-separator
  539. ----
  540. .. _class_TileMap_method_set_cells_terrain_path:
  541. .. rst-class:: classref-method
  542. |void| **set_cells_terrain_path**\ (\ layer\: :ref:`int<class_int>`, path\: :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\], terrain_set\: :ref:`int<class_int>`, terrain\: :ref:`int<class_int>`, ignore_empty_terrains\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_TileMap_method_set_cells_terrain_path>`
  543. Update all the cells in the ``path`` coordinates array so that they use the given ``terrain`` for the given ``terrain_set``. The function will also connect two successive cell in the path with the same terrain. This function might update neighboring tiles if needed to create correct terrain transitions.
  544. If ``ignore_empty_terrains`` is ``true``, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
  545. If ``layer`` is negative, the layers are accessed from the last one.
  546. \ **Note:** To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
  547. .. rst-class:: classref-item-separator
  548. ----
  549. .. _class_TileMap_method_set_layer_enabled:
  550. .. rst-class:: classref-method
  551. |void| **set_layer_enabled**\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_TileMap_method_set_layer_enabled>`
  552. Enables or disables the layer ``layer``. A disabled layer is not processed at all (no rendering, no physics, etc.).
  553. If ``layer`` is negative, the layers are accessed from the last one.
  554. .. rst-class:: classref-item-separator
  555. ----
  556. .. _class_TileMap_method_set_layer_modulate:
  557. .. rst-class:: classref-method
  558. |void| **set_layer_modulate**\ (\ layer\: :ref:`int<class_int>`, modulate\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_TileMap_method_set_layer_modulate>`
  559. Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate.
  560. If ``layer`` is negative, the layers are accessed from the last one.
  561. .. rst-class:: classref-item-separator
  562. ----
  563. .. _class_TileMap_method_set_layer_name:
  564. .. rst-class:: classref-method
  565. |void| **set_layer_name**\ (\ layer\: :ref:`int<class_int>`, name\: :ref:`String<class_String>`\ ) :ref:`🔗<class_TileMap_method_set_layer_name>`
  566. Sets a layer's name. This is mostly useful in the editor.
  567. If ``layer`` is negative, the layers are accessed from the last one.
  568. .. rst-class:: classref-item-separator
  569. ----
  570. .. _class_TileMap_method_set_layer_navigation_enabled:
  571. .. rst-class:: classref-method
  572. |void| **set_layer_navigation_enabled**\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_TileMap_method_set_layer_navigation_enabled>`
  573. Enables or disables a layer's built-in navigation regions generation. Disable this if you need to bake navigation regions from a TileMap using a :ref:`NavigationRegion2D<class_NavigationRegion2D>` node.
  574. .. rst-class:: classref-item-separator
  575. ----
  576. .. _class_TileMap_method_set_layer_navigation_map:
  577. .. rst-class:: classref-method
  578. |void| **set_layer_navigation_map**\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_set_layer_navigation_map>`
  579. Assigns ``map`` as a :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map for the specified TileMap layer ``layer``.
  580. By default the TileMap uses the default :ref:`World2D<class_World2D>` navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer.
  581. In order to make :ref:`NavigationAgent2D<class_NavigationAgent2D>` switch between TileMap layer navigation maps use :ref:`NavigationAgent2D.set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>` with the navigation map received from :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`.
  582. If ``layer`` is negative, the layers are accessed from the last one.
  583. .. rst-class:: classref-item-separator
  584. ----
  585. .. _class_TileMap_method_set_layer_y_sort_enabled:
  586. .. rst-class:: classref-method
  587. |void| **set_layer_y_sort_enabled**\ (\ layer\: :ref:`int<class_int>`, y_sort_enabled\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_TileMap_method_set_layer_y_sort_enabled>`
  588. 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.
  589. 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 behavior.
  590. If ``layer`` is negative, the layers are accessed from the last one.
  591. .. rst-class:: classref-item-separator
  592. ----
  593. .. _class_TileMap_method_set_layer_y_sort_origin:
  594. .. rst-class:: classref-method
  595. |void| **set_layer_y_sort_origin**\ (\ layer\: :ref:`int<class_int>`, y_sort_origin\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_set_layer_y_sort_origin>`
  596. Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value.
  597. This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games.
  598. If ``layer`` is negative, the layers are accessed from the last one.
  599. .. rst-class:: classref-item-separator
  600. ----
  601. .. _class_TileMap_method_set_layer_z_index:
  602. .. rst-class:: classref-method
  603. |void| **set_layer_z_index**\ (\ layer\: :ref:`int<class_int>`, z_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_set_layer_z_index>`
  604. Sets a layers Z-index value. This Z-index is added to each tile's Z-index value.
  605. If ``layer`` is negative, the layers are accessed from the last one.
  606. .. rst-class:: classref-item-separator
  607. ----
  608. .. _class_TileMap_method_set_navigation_map:
  609. .. rst-class:: classref-method
  610. |void| **set_navigation_map**\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_set_navigation_map>`
  611. **Deprecated:** Use :ref:`set_layer_navigation_map<class_TileMap_method_set_layer_navigation_map>` instead.
  612. Assigns ``map`` as a :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map for the specified TileMap layer ``layer``.
  613. .. rst-class:: classref-item-separator
  614. ----
  615. .. _class_TileMap_method_set_pattern:
  616. .. rst-class:: classref-method
  617. |void| **set_pattern**\ (\ layer\: :ref:`int<class_int>`, position\: :ref:`Vector2i<class_Vector2i>`, pattern\: :ref:`TileMapPattern<class_TileMapPattern>`\ ) :ref:`🔗<class_TileMap_method_set_pattern>`
  618. Paste the given :ref:`TileMapPattern<class_TileMapPattern>` at the given ``position`` and ``layer`` in the tile map.
  619. If ``layer`` is negative, the layers are accessed from the last one.
  620. .. rst-class:: classref-item-separator
  621. ----
  622. .. _class_TileMap_method_update_internals:
  623. .. rst-class:: classref-method
  624. |void| **update_internals**\ (\ ) :ref:`🔗<class_TileMap_method_update_internals>`
  625. Triggers a direct update of the TileMap. Usually, calling this function is not needed, as TileMap node updates automatically when one of its properties or cells is modified.
  626. However, for performance reasons, those updates are batched and delayed to the end of the frame. Calling this function will force the TileMap to update right away instead.
  627. \ **Warning:** Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of updates and how many tiles they impact.
  628. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  629. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  630. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  631. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  632. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  633. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  634. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  635. .. |void| replace:: :abbr:`void (No return value.)`