class_tilemap.rst 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  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. - `2D Dynamic TileMap Layers Demo <https://godotengine.org/asset-library/asset/2713>`__
  31. .. rst-class:: classref-reftable-group
  32. Properties
  33. ----------
  34. .. table::
  35. :widths: auto
  36. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  37. | :ref:`bool<class_bool>` | :ref:`collision_animatable<class_TileMap_property_collision_animatable>` | ``false`` |
  38. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  39. | :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`collision_visibility_mode<class_TileMap_property_collision_visibility_mode>` | ``0`` |
  40. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  41. | :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`navigation_visibility_mode<class_TileMap_property_navigation_visibility_mode>` | ``0`` |
  42. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  43. | :ref:`int<class_int>` | :ref:`rendering_quadrant_size<class_TileMap_property_rendering_quadrant_size>` | ``16`` |
  44. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  45. | :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` | |
  46. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  47. .. rst-class:: classref-reftable-group
  48. Methods
  49. -------
  50. .. table::
  51. :widths: auto
  52. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | |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| |
  54. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :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| |
  56. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | |void| | :ref:`add_layer<class_TileMap_method_add_layer>`\ (\ to_position\: :ref:`int<class_int>`\ ) |
  58. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | |void| | :ref:`clear<class_TileMap_method_clear>`\ (\ ) |
  60. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | |void| | :ref:`clear_layer<class_TileMap_method_clear_layer>`\ (\ layer\: :ref:`int<class_int>`\ ) |
  62. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | |void| | :ref:`erase_cell<class_TileMap_method_erase_cell>`\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`\ ) |
  64. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | |void| | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>`\ (\ ) |
  66. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | |void| | :ref:`force_update<class_TileMap_method_force_update>`\ (\ layer\: :ref:`int<class_int>` = -1\ ) |
  68. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :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| |
  70. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :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| |
  72. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :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| |
  74. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :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| |
  76. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_coords_for_body_rid<class_TileMap_method_get_coords_for_body_rid>`\ (\ body\: :ref:`RID<class_RID>`\ ) |
  78. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`int<class_int>` | :ref:`get_layer_for_body_rid<class_TileMap_method_get_layer_for_body_rid>`\ (\ body\: :ref:`RID<class_RID>`\ ) |
  80. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`Color<class_Color>` | :ref:`get_layer_modulate<class_TileMap_method_get_layer_modulate>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  82. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`String<class_String>` | :ref:`get_layer_name<class_TileMap_method_get_layer_name>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  84. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`RID<class_RID>` | :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  86. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`int<class_int>` | :ref:`get_layer_y_sort_origin<class_TileMap_method_get_layer_y_sort_origin>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  88. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`int<class_int>` | :ref:`get_layer_z_index<class_TileMap_method_get_layer_z_index>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  90. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`int<class_int>` | :ref:`get_layers_count<class_TileMap_method_get_layers_count>`\ (\ ) |const| |
  92. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_TileMap_method_get_navigation_map>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  94. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :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| |
  96. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :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>`\]\ ) |
  98. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] | :ref:`get_surrounding_cells<class_TileMap_method_get_surrounding_cells>`\ (\ coords\: :ref:`Vector2i<class_Vector2i>`\ ) |
  100. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] | :ref:`get_used_cells<class_TileMap_method_get_used_cells>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  102. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :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| |
  104. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`Rect2i<class_Rect2i>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>`\ (\ ) |const| |
  106. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :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| |
  108. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :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| |
  110. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :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| |
  112. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`bool<class_bool>` | :ref:`is_layer_enabled<class_TileMap_method_is_layer_enabled>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  114. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`bool<class_bool>` | :ref:`is_layer_navigation_enabled<class_TileMap_method_is_layer_navigation_enabled>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  116. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`bool<class_bool>` | :ref:`is_layer_y_sort_enabled<class_TileMap_method_is_layer_y_sort_enabled>`\ (\ layer\: :ref:`int<class_int>`\ ) |const| |
  118. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`Vector2i<class_Vector2i>` | :ref:`local_to_map<class_TileMap_method_local_to_map>`\ (\ local_position\: :ref:`Vector2<class_Vector2>`\ ) |const| |
  120. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :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>`\ ) |
  122. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`Vector2<class_Vector2>` | :ref:`map_to_local<class_TileMap_method_map_to_local>`\ (\ map_position\: :ref:`Vector2i<class_Vector2i>`\ ) |const| |
  124. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | |void| | :ref:`move_layer<class_TileMap_method_move_layer>`\ (\ layer\: :ref:`int<class_int>`, to_position\: :ref:`int<class_int>`\ ) |
  126. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | |void| | :ref:`notify_runtime_tile_data_update<class_TileMap_method_notify_runtime_tile_data_update>`\ (\ layer\: :ref:`int<class_int>` = -1\ ) |
  128. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | |void| | :ref:`remove_layer<class_TileMap_method_remove_layer>`\ (\ layer\: :ref:`int<class_int>`\ ) |
  130. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | |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\ ) |
  132. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | |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\ ) |
  134. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | |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\ ) |
  136. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | |void| | :ref:`set_layer_enabled<class_TileMap_method_set_layer_enabled>`\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) |
  138. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | |void| | :ref:`set_layer_modulate<class_TileMap_method_set_layer_modulate>`\ (\ layer\: :ref:`int<class_int>`, modulate\: :ref:`Color<class_Color>`\ ) |
  140. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | |void| | :ref:`set_layer_name<class_TileMap_method_set_layer_name>`\ (\ layer\: :ref:`int<class_int>`, name\: :ref:`String<class_String>`\ ) |
  142. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | |void| | :ref:`set_layer_navigation_enabled<class_TileMap_method_set_layer_navigation_enabled>`\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) |
  144. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | |void| | :ref:`set_layer_navigation_map<class_TileMap_method_set_layer_navigation_map>`\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) |
  146. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | |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>`\ ) |
  148. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | |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>`\ ) |
  150. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | |void| | :ref:`set_layer_z_index<class_TileMap_method_set_layer_z_index>`\ (\ layer\: :ref:`int<class_int>`, z_index\: :ref:`int<class_int>`\ ) |
  152. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | |void| | :ref:`set_navigation_map<class_TileMap_method_set_navigation_map>`\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) |
  154. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | |void| | :ref:`set_pattern<class_TileMap_method_set_pattern>`\ (\ layer\: :ref:`int<class_int>`, position\: :ref:`Vector2i<class_Vector2i>`, pattern\: :ref:`TileMapPattern<class_TileMapPattern>`\ ) |
  156. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | |void| | :ref:`update_internals<class_TileMap_method_update_internals>`\ (\ ) |
  158. +--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. .. rst-class:: classref-section-separator
  160. ----
  161. .. rst-class:: classref-descriptions-group
  162. Signals
  163. -------
  164. .. _class_TileMap_signal_changed:
  165. .. rst-class:: classref-signal
  166. **changed**\ (\ ) :ref:`🔗<class_TileMap_signal_changed>`
  167. Emitted when the :ref:`TileSet<class_TileSet>` of this TileMap changes.
  168. .. rst-class:: classref-section-separator
  169. ----
  170. .. rst-class:: classref-descriptions-group
  171. Enumerations
  172. ------------
  173. .. _enum_TileMap_VisibilityMode:
  174. .. rst-class:: classref-enumeration
  175. enum **VisibilityMode**: :ref:`🔗<enum_TileMap_VisibilityMode>`
  176. .. _class_TileMap_constant_VISIBILITY_MODE_DEFAULT:
  177. .. rst-class:: classref-enumeration-constant
  178. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_DEFAULT** = ``0``
  179. Use the debug settings to determine visibility.
  180. .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_HIDE:
  181. .. rst-class:: classref-enumeration-constant
  182. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_FORCE_HIDE** = ``2``
  183. Always hide.
  184. .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_SHOW:
  185. .. rst-class:: classref-enumeration-constant
  186. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_FORCE_SHOW** = ``1``
  187. Always show.
  188. .. rst-class:: classref-section-separator
  189. ----
  190. .. rst-class:: classref-descriptions-group
  191. Property Descriptions
  192. ---------------------
  193. .. _class_TileMap_property_collision_animatable:
  194. .. rst-class:: classref-property
  195. :ref:`bool<class_bool>` **collision_animatable** = ``false`` :ref:`🔗<class_TileMap_property_collision_animatable>`
  196. .. rst-class:: classref-property-setget
  197. - |void| **set_collision_animatable**\ (\ value\: :ref:`bool<class_bool>`\ )
  198. - :ref:`bool<class_bool>` **is_collision_animatable**\ (\ )
  199. 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.
  200. \ **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.
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_TileMap_property_collision_visibility_mode:
  204. .. rst-class:: classref-property
  205. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **collision_visibility_mode** = ``0`` :ref:`🔗<class_TileMap_property_collision_visibility_mode>`
  206. .. rst-class:: classref-property-setget
  207. - |void| **set_collision_visibility_mode**\ (\ value\: :ref:`VisibilityMode<enum_TileMap_VisibilityMode>`\ )
  208. - :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **get_collision_visibility_mode**\ (\ )
  209. 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.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_TileMap_property_navigation_visibility_mode:
  213. .. rst-class:: classref-property
  214. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **navigation_visibility_mode** = ``0`` :ref:`🔗<class_TileMap_property_navigation_visibility_mode>`
  215. .. rst-class:: classref-property-setget
  216. - |void| **set_navigation_visibility_mode**\ (\ value\: :ref:`VisibilityMode<enum_TileMap_VisibilityMode>`\ )
  217. - :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **get_navigation_visibility_mode**\ (\ )
  218. 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.
  219. .. rst-class:: classref-item-separator
  220. ----
  221. .. _class_TileMap_property_rendering_quadrant_size:
  222. .. rst-class:: classref-property
  223. :ref:`int<class_int>` **rendering_quadrant_size** = ``16`` :ref:`🔗<class_TileMap_property_rendering_quadrant_size>`
  224. .. rst-class:: classref-property-setget
  225. - |void| **set_rendering_quadrant_size**\ (\ value\: :ref:`int<class_int>`\ )
  226. - :ref:`int<class_int>` **get_rendering_quadrant_size**\ (\ )
  227. 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.
  228. The quadrant size does not apply on Y-sorted layers, as tiles are grouped by Y position instead in that case.
  229. \ **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.
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_TileMap_property_tile_set:
  233. .. rst-class:: classref-property
  234. :ref:`TileSet<class_TileSet>` **tile_set** :ref:`🔗<class_TileMap_property_tile_set>`
  235. .. rst-class:: classref-property-setget
  236. - |void| **set_tileset**\ (\ value\: :ref:`TileSet<class_TileSet>`\ )
  237. - :ref:`TileSet<class_TileSet>` **get_tileset**\ (\ )
  238. The :ref:`TileSet<class_TileSet>` used by this **TileMap**. The textures, collisions, and additional behavior of all available tiles are stored here.
  239. .. rst-class:: classref-section-separator
  240. ----
  241. .. rst-class:: classref-descriptions-group
  242. Method Descriptions
  243. -------------------
  244. .. _class_TileMap_private_method__tile_data_runtime_update:
  245. .. rst-class:: classref-method
  246. |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>`
  247. Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime.
  248. 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``.
  249. \ **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.
  250. \ **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.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_TileMap_private_method__use_tile_data_runtime_update:
  254. .. rst-class:: classref-method
  255. :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>`
  256. Should return ``true`` if the tile at coordinates ``coords`` on layer ``layer`` requires a runtime update.
  257. \ **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.
  258. \ **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.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_TileMap_method_add_layer:
  262. .. rst-class:: classref-method
  263. |void| **add_layer**\ (\ to_position\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_add_layer>`
  264. 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.
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_TileMap_method_clear:
  268. .. rst-class:: classref-method
  269. |void| **clear**\ (\ ) :ref:`🔗<class_TileMap_method_clear>`
  270. Clears all cells.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_TileMap_method_clear_layer:
  274. .. rst-class:: classref-method
  275. |void| **clear_layer**\ (\ layer\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_clear_layer>`
  276. Clears all cells on the given layer.
  277. If ``layer`` is negative, the layers are accessed from the last one.
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_TileMap_method_erase_cell:
  281. .. rst-class:: classref-method
  282. |void| **erase_cell**\ (\ layer\: :ref:`int<class_int>`, coords\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`🔗<class_TileMap_method_erase_cell>`
  283. Erases the cell on layer ``layer`` at coordinates ``coords``.
  284. If ``layer`` is negative, the layers are accessed from the last one.
  285. .. rst-class:: classref-item-separator
  286. ----
  287. .. _class_TileMap_method_fix_invalid_tiles:
  288. .. rst-class:: classref-method
  289. |void| **fix_invalid_tiles**\ (\ ) :ref:`🔗<class_TileMap_method_fix_invalid_tiles>`
  290. Clears cells that do not exist in the tileset.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_TileMap_method_force_update:
  294. .. rst-class:: classref-method
  295. |void| **force_update**\ (\ layer\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_TileMap_method_force_update>`
  296. **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.
  297. Forces the TileMap and the layer ``layer`` to update.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_TileMap_method_get_cell_alternative_tile:
  301. .. rst-class:: classref-method
  302. :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>`
  303. Returns the tile alternative ID of the cell on layer ``layer`` at ``coords``.
  304. 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>`.
  305. If ``layer`` is negative, the layers are accessed from the last one.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_TileMap_method_get_cell_atlas_coords:
  309. .. rst-class:: classref-method
  310. :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>`
  311. 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.
  312. 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>`.
  313. If ``layer`` is negative, the layers are accessed from the last one.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_TileMap_method_get_cell_source_id:
  317. .. rst-class:: classref-method
  318. :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>`
  319. Returns the tile source ID of the cell on layer ``layer`` at coordinates ``coords``. Returns ``-1`` if the cell does not exist.
  320. 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>`.
  321. If ``layer`` is negative, the layers are accessed from the last one.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_TileMap_method_get_cell_tile_data:
  325. .. rst-class:: classref-method
  326. :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>`
  327. 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>`.
  328. If ``layer`` is negative, the layers are accessed from the last one.
  329. ::
  330. func get_clicked_tile_power():
  331. var clicked_cell = tile_map.local_to_map(tile_map.get_local_mouse_position())
  332. var data = tile_map.get_cell_tile_data(0, clicked_cell)
  333. if data:
  334. return data.get_custom_data("power")
  335. else:
  336. return 0
  337. 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>`.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_TileMap_method_get_coords_for_body_rid:
  341. .. rst-class:: classref-method
  342. :ref:`Vector2i<class_Vector2i>` **get_coords_for_body_rid**\ (\ body\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_get_coords_for_body_rid>`
  343. 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.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_TileMap_method_get_layer_for_body_rid:
  347. .. rst-class:: classref-method
  348. :ref:`int<class_int>` **get_layer_for_body_rid**\ (\ body\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_get_layer_for_body_rid>`
  349. 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.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_TileMap_method_get_layer_modulate:
  353. .. rst-class:: classref-method
  354. :ref:`Color<class_Color>` **get_layer_modulate**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_modulate>`
  355. Returns a TileMap layer's modulate.
  356. If ``layer`` is negative, the layers are accessed from the last one.
  357. .. rst-class:: classref-item-separator
  358. ----
  359. .. _class_TileMap_method_get_layer_name:
  360. .. rst-class:: classref-method
  361. :ref:`String<class_String>` **get_layer_name**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_name>`
  362. Returns a TileMap layer's name.
  363. If ``layer`` is negative, the layers are accessed from the last one.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_TileMap_method_get_layer_navigation_map:
  367. .. rst-class:: classref-method
  368. :ref:`RID<class_RID>` **get_layer_navigation_map**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_navigation_map>`
  369. Returns the :ref:`RID<class_RID>` of the :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map assigned to the specified TileMap layer ``layer``.
  370. 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.
  371. 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>`.
  372. If ``layer`` is negative, the layers are accessed from the last one.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_TileMap_method_get_layer_y_sort_origin:
  376. .. rst-class:: classref-method
  377. :ref:`int<class_int>` **get_layer_y_sort_origin**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_y_sort_origin>`
  378. Returns a TileMap layer's Y sort origin.
  379. If ``layer`` is negative, the layers are accessed from the last one.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_TileMap_method_get_layer_z_index:
  383. .. rst-class:: classref-method
  384. :ref:`int<class_int>` **get_layer_z_index**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_layer_z_index>`
  385. Returns a TileMap layer's Z-index value.
  386. If ``layer`` is negative, the layers are accessed from the last one.
  387. .. rst-class:: classref-item-separator
  388. ----
  389. .. _class_TileMap_method_get_layers_count:
  390. .. rst-class:: classref-method
  391. :ref:`int<class_int>` **get_layers_count**\ (\ ) |const| :ref:`🔗<class_TileMap_method_get_layers_count>`
  392. Returns the number of layers in the TileMap.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_TileMap_method_get_navigation_map:
  396. .. rst-class:: classref-method
  397. :ref:`RID<class_RID>` **get_navigation_map**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_navigation_map>`
  398. **Deprecated:** Use :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>` instead.
  399. Returns the :ref:`RID<class_RID>` of the :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map assigned to the specified TileMap layer ``layer``.
  400. .. rst-class:: classref-item-separator
  401. ----
  402. .. _class_TileMap_method_get_neighbor_cell:
  403. .. rst-class:: classref-method
  404. :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>`
  405. 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.
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_TileMap_method_get_pattern:
  409. .. rst-class:: classref-method
  410. :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>`
  411. Creates a new :ref:`TileMapPattern<class_TileMapPattern>` from the given layer and set of cells.
  412. If ``layer`` is negative, the layers are accessed from the last one.
  413. .. rst-class:: classref-item-separator
  414. ----
  415. .. _class_TileMap_method_get_surrounding_cells:
  416. .. rst-class:: classref-method
  417. :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] **get_surrounding_cells**\ (\ coords\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`🔗<class_TileMap_method_get_surrounding_cells>`
  418. Returns the list of all neighbourings cells to the one at ``coords``.
  419. .. rst-class:: classref-item-separator
  420. ----
  421. .. _class_TileMap_method_get_used_cells:
  422. .. rst-class:: classref-method
  423. :ref:`Array<class_Array>`\[:ref:`Vector2i<class_Vector2i>`\] **get_used_cells**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_get_used_cells>`
  424. 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.
  425. If ``layer`` is negative, the layers are accessed from the last one.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_TileMap_method_get_used_cells_by_id:
  429. .. rst-class:: classref-method
  430. :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>`
  431. 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``).
  432. 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>`.
  433. 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.
  434. If ``layer`` is negative, the layers are accessed from the last one.
  435. .. rst-class:: classref-item-separator
  436. ----
  437. .. _class_TileMap_method_get_used_rect:
  438. .. rst-class:: classref-method
  439. :ref:`Rect2i<class_Rect2i>` **get_used_rect**\ (\ ) |const| :ref:`🔗<class_TileMap_method_get_used_rect>`
  440. Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers.
  441. .. rst-class:: classref-item-separator
  442. ----
  443. .. _class_TileMap_method_is_cell_flipped_h:
  444. .. rst-class:: classref-method
  445. :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>`
  446. Returns ``true`` if the cell on layer ``layer`` at coordinates ``coords`` is flipped horizontally. The result is valid only for atlas sources.
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_TileMap_method_is_cell_flipped_v:
  450. .. rst-class:: classref-method
  451. :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>`
  452. Returns ``true`` if the cell on layer ``layer`` at coordinates ``coords`` is flipped vertically. The result is valid only for atlas sources.
  453. .. rst-class:: classref-item-separator
  454. ----
  455. .. _class_TileMap_method_is_cell_transposed:
  456. .. rst-class:: classref-method
  457. :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>`
  458. Returns ``true`` if the cell on layer ``layer`` at coordinates ``coords`` is transposed. The result is valid only for atlas sources.
  459. .. rst-class:: classref-item-separator
  460. ----
  461. .. _class_TileMap_method_is_layer_enabled:
  462. .. rst-class:: classref-method
  463. :ref:`bool<class_bool>` **is_layer_enabled**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_is_layer_enabled>`
  464. Returns if a layer is enabled.
  465. If ``layer`` is negative, the layers are accessed from the last one.
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_TileMap_method_is_layer_navigation_enabled:
  469. .. rst-class:: classref-method
  470. :ref:`bool<class_bool>` **is_layer_navigation_enabled**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_is_layer_navigation_enabled>`
  471. Returns if a layer's built-in navigation regions generation is enabled.
  472. .. rst-class:: classref-item-separator
  473. ----
  474. .. _class_TileMap_method_is_layer_y_sort_enabled:
  475. .. rst-class:: classref-method
  476. :ref:`bool<class_bool>` **is_layer_y_sort_enabled**\ (\ layer\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileMap_method_is_layer_y_sort_enabled>`
  477. Returns if a layer Y-sorts its tiles.
  478. If ``layer`` is negative, the layers are accessed from the last one.
  479. .. rst-class:: classref-item-separator
  480. ----
  481. .. _class_TileMap_method_local_to_map:
  482. .. rst-class:: classref-method
  483. :ref:`Vector2i<class_Vector2i>` **local_to_map**\ (\ local_position\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_TileMap_method_local_to_map>`
  484. 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>`.
  485. .. rst-class:: classref-item-separator
  486. ----
  487. .. _class_TileMap_method_map_pattern:
  488. .. rst-class:: classref-method
  489. :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>`
  490. 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``.
  491. .. rst-class:: classref-item-separator
  492. ----
  493. .. _class_TileMap_method_map_to_local:
  494. .. rst-class:: classref-method
  495. :ref:`Vector2<class_Vector2>` **map_to_local**\ (\ map_position\: :ref:`Vector2i<class_Vector2i>`\ ) |const| :ref:`🔗<class_TileMap_method_map_to_local>`
  496. 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>`.
  497. \ **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.
  498. .. rst-class:: classref-item-separator
  499. ----
  500. .. _class_TileMap_method_move_layer:
  501. .. rst-class:: classref-method
  502. |void| **move_layer**\ (\ layer\: :ref:`int<class_int>`, to_position\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_move_layer>`
  503. Moves the layer at index ``layer`` to the given position ``to_position`` in the array.
  504. .. rst-class:: classref-item-separator
  505. ----
  506. .. _class_TileMap_method_notify_runtime_tile_data_update:
  507. .. rst-class:: classref-method
  508. |void| **notify_runtime_tile_data_update**\ (\ layer\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_TileMap_method_notify_runtime_tile_data_update>`
  509. 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.
  510. If ``layer`` is provided, only notifies changes for the given layer. Providing the ``layer`` argument (when applicable) is usually preferred for performance reasons.
  511. \ **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.
  512. \ **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>`).
  513. .. rst-class:: classref-item-separator
  514. ----
  515. .. _class_TileMap_method_remove_layer:
  516. .. rst-class:: classref-method
  517. |void| **remove_layer**\ (\ layer\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_remove_layer>`
  518. Removes the layer at index ``layer``.
  519. .. rst-class:: classref-item-separator
  520. ----
  521. .. _class_TileMap_method_set_cell:
  522. .. rst-class:: classref-method
  523. |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>`
  524. 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:
  525. - The source identifier ``source_id`` identifies a :ref:`TileSetSource<class_TileSetSource>` identifier. See :ref:`TileSet.set_source_id<class_TileSet_method_set_source_id>`,
  526. - 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)``),
  527. - 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>`.
  528. 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``.
  529. If ``layer`` is negative, the layers are accessed from the last one.
  530. .. rst-class:: classref-item-separator
  531. ----
  532. .. _class_TileMap_method_set_cells_terrain_connect:
  533. .. rst-class:: classref-method
  534. |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>`
  535. 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.
  536. If ``ignore_empty_terrains`` is ``true``, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
  537. If ``layer`` is negative, the layers are accessed from the last one.
  538. \ **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.
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _class_TileMap_method_set_cells_terrain_path:
  542. .. rst-class:: classref-method
  543. |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>`
  544. 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.
  545. If ``ignore_empty_terrains`` is ``true``, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
  546. If ``layer`` is negative, the layers are accessed from the last one.
  547. \ **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.
  548. .. rst-class:: classref-item-separator
  549. ----
  550. .. _class_TileMap_method_set_layer_enabled:
  551. .. rst-class:: classref-method
  552. |void| **set_layer_enabled**\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_TileMap_method_set_layer_enabled>`
  553. Enables or disables the layer ``layer``. A disabled layer is not processed at all (no rendering, no physics, etc.).
  554. If ``layer`` is negative, the layers are accessed from the last one.
  555. .. rst-class:: classref-item-separator
  556. ----
  557. .. _class_TileMap_method_set_layer_modulate:
  558. .. rst-class:: classref-method
  559. |void| **set_layer_modulate**\ (\ layer\: :ref:`int<class_int>`, modulate\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_TileMap_method_set_layer_modulate>`
  560. Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate.
  561. If ``layer`` is negative, the layers are accessed from the last one.
  562. .. rst-class:: classref-item-separator
  563. ----
  564. .. _class_TileMap_method_set_layer_name:
  565. .. rst-class:: classref-method
  566. |void| **set_layer_name**\ (\ layer\: :ref:`int<class_int>`, name\: :ref:`String<class_String>`\ ) :ref:`🔗<class_TileMap_method_set_layer_name>`
  567. Sets a layer's name. This is mostly useful in the editor.
  568. If ``layer`` is negative, the layers are accessed from the last one.
  569. .. rst-class:: classref-item-separator
  570. ----
  571. .. _class_TileMap_method_set_layer_navigation_enabled:
  572. .. rst-class:: classref-method
  573. |void| **set_layer_navigation_enabled**\ (\ layer\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_TileMap_method_set_layer_navigation_enabled>`
  574. 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.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_TileMap_method_set_layer_navigation_map:
  578. .. rst-class:: classref-method
  579. |void| **set_layer_navigation_map**\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_set_layer_navigation_map>`
  580. Assigns ``map`` as a :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map for the specified TileMap layer ``layer``.
  581. 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.
  582. 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>`.
  583. If ``layer`` is negative, the layers are accessed from the last one.
  584. .. rst-class:: classref-item-separator
  585. ----
  586. .. _class_TileMap_method_set_layer_y_sort_enabled:
  587. .. rst-class:: classref-method
  588. |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>`
  589. 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.
  590. 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.
  591. If ``layer`` is negative, the layers are accessed from the last one.
  592. .. rst-class:: classref-item-separator
  593. ----
  594. .. _class_TileMap_method_set_layer_y_sort_origin:
  595. .. rst-class:: classref-method
  596. |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>`
  597. Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value.
  598. This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games.
  599. If ``layer`` is negative, the layers are accessed from the last one.
  600. .. rst-class:: classref-item-separator
  601. ----
  602. .. _class_TileMap_method_set_layer_z_index:
  603. .. rst-class:: classref-method
  604. |void| **set_layer_z_index**\ (\ layer\: :ref:`int<class_int>`, z_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileMap_method_set_layer_z_index>`
  605. Sets a layers Z-index value. This Z-index is added to each tile's Z-index value.
  606. If ``layer`` is negative, the layers are accessed from the last one.
  607. .. rst-class:: classref-item-separator
  608. ----
  609. .. _class_TileMap_method_set_navigation_map:
  610. .. rst-class:: classref-method
  611. |void| **set_navigation_map**\ (\ layer\: :ref:`int<class_int>`, map\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_TileMap_method_set_navigation_map>`
  612. **Deprecated:** Use :ref:`set_layer_navigation_map<class_TileMap_method_set_layer_navigation_map>` instead.
  613. Assigns ``map`` as a :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map for the specified TileMap layer ``layer``.
  614. .. rst-class:: classref-item-separator
  615. ----
  616. .. _class_TileMap_method_set_pattern:
  617. .. rst-class:: classref-method
  618. |void| **set_pattern**\ (\ layer\: :ref:`int<class_int>`, position\: :ref:`Vector2i<class_Vector2i>`, pattern\: :ref:`TileMapPattern<class_TileMapPattern>`\ ) :ref:`🔗<class_TileMap_method_set_pattern>`
  619. Paste the given :ref:`TileMapPattern<class_TileMapPattern>` at the given ``position`` and ``layer`` in the tile map.
  620. If ``layer`` is negative, the layers are accessed from the last one.
  621. .. rst-class:: classref-item-separator
  622. ----
  623. .. _class_TileMap_method_update_internals:
  624. .. rst-class:: classref-method
  625. |void| **update_internals**\ (\ ) :ref:`🔗<class_TileMap_method_update_internals>`
  626. 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.
  627. 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.
  628. \ **Warning:** Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of updates and how many tiles they impact.
  629. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  630. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  631. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  632. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  633. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  634. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  635. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  636. .. |void| replace:: :abbr:`void (No return value.)`