virtualx-engine-docs/_sources/classes/class_tilemap.rst.txt

992 lines
48 KiB
Text
Raw Permalink Normal View History

2024-10-23 18:41:33 +02:00
:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/TileMap.xml.
.. _class_TileMap:
TileMap
=======
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
Node for 2D tile-based maps.
.. rst-class:: classref-introduction-group
Description
-----------
Node for 2D tile-based maps. Tilemaps use a :ref:`TileSet<class_TileSet>` which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps.
When doing physics queries against the tilemap, the cell coordinates are encoded as ``metadata`` for each detected collision shape returned by methods such as :ref:`Physics2DDirectSpaceState.intersect_shape<class_Physics2DDirectSpaceState_method_intersect_shape>`, :ref:`Physics2DDirectBodyState.get_contact_collider_shape_metadata<class_Physics2DDirectBodyState_method_get_contact_collider_shape_metadata>`, etc.
.. rst-class:: classref-introduction-group
Tutorials
---------
- :doc:`Using Tilemaps <../tutorials/2d/using_tilemaps>`
- `2D Platformer Demo <https://godotengine.org/asset-library/asset/120>`__
- `2D Isometric Demo <https://godotengine.org/asset-library/asset/112>`__
- `2D Hexagonal Demo <https://godotengine.org/asset-library/asset/111>`__
- `2D Navigation Astar Demo <https://godotengine.org/asset-library/asset/519>`__
- `2D Role Playing Game Demo <https://godotengine.org/asset-library/asset/520>`__
- `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/113>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`bake_navigation<class_TileMap_property_bake_navigation>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`cell_clip_uv<class_TileMap_property_cell_clip_uv>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`Transform2D<class_Transform2D>` | :ref:`cell_custom_transform<class_TileMap_property_cell_custom_transform>` | ``Transform2D( 64, 0, 0, 64, 0, 0 )`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`HalfOffset<enum_TileMap_HalfOffset>` | :ref:`cell_half_offset<class_TileMap_property_cell_half_offset>` | ``2`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`int<class_int>` | :ref:`cell_quadrant_size<class_TileMap_property_cell_quadrant_size>` | ``16`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`cell_size<class_TileMap_property_cell_size>` | ``Vector2( 64, 64 )`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`TileOrigin<enum_TileMap_TileOrigin>` | :ref:`cell_tile_origin<class_TileMap_property_cell_tile_origin>` | ``0`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`cell_y_sort<class_TileMap_property_cell_y_sort>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`centered_textures<class_TileMap_property_centered_textures>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`float<class_float>` | :ref:`collision_bounce<class_TileMap_property_collision_bounce>` | ``0.0`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`float<class_float>` | :ref:`collision_friction<class_TileMap_property_collision_friction>` | ``1.0`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`int<class_int>` | :ref:`collision_layer<class_TileMap_property_collision_layer>` | ``1`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`int<class_int>` | :ref:`collision_mask<class_TileMap_property_collision_mask>` | ``1`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`collision_use_kinematic<class_TileMap_property_collision_use_kinematic>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`collision_use_parent<class_TileMap_property_collision_use_parent>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`compatibility_mode<class_TileMap_property_compatibility_mode>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`Mode<enum_TileMap_Mode>` | :ref:`mode<class_TileMap_property_mode>` | ``0`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`int<class_int>` | :ref:`navigation_layers<class_TileMap_property_navigation_layers>` | ``1`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`int<class_int>` | :ref:`occluder_light_mask<class_TileMap_property_occluder_light_mask>` | ``1`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`bool<class_bool>` | :ref:`show_collision<class_TileMap_property_show_collision>` | ``false`` |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
| :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` | |
+--------------------------------------------+--------------------------------------------------------------------------------+---------------------------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_TileMap_method_clear>` **(** **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>` **(** **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_cell<class_TileMap_method_get_cell>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`get_cell_autotile_coord<class_TileMap_method_get_cell_autotile_coord>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_cellv<class_TileMap_method_get_cellv>` **(** :ref:`Vector2<class_Vector2>` position **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_TileMap_method_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_TileMap_method_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`get_used_cells<class_TileMap_method_get_used_cells>` **(** **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`get_used_cells_by_id<class_TileMap_method_get_used_cells_by_id>` **(** :ref:`int<class_int>` id **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Rect2<class_Rect2>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>` **(** **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_cell_transposed<class_TileMap_method_is_cell_transposed>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_cell_x_flipped<class_TileMap_method_is_cell_x_flipped>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_cell_y_flipped<class_TileMap_method_is_cell_y_flipped>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`map_to_world<class_TileMap_method_map_to_world>` **(** :ref:`Vector2<class_Vector2>` map_position, :ref:`bool<class_bool>` ignore_half_ofs=false **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_cell<class_TileMap_method_set_cell>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false, :ref:`Vector2<class_Vector2>` autotile_coord=Vector2( 0, 0 ) **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_cellv<class_TileMap_method_set_cellv>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false, :ref:`Vector2<class_Vector2>` autotile_coord=Vector2( 0, 0 ) **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_collision_layer_bit<class_TileMap_method_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_collision_mask_bit<class_TileMap_method_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`update_bitmask_area<class_TileMap_method_update_bitmask_area>` **(** :ref:`Vector2<class_Vector2>` position **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`update_bitmask_region<class_TileMap_method_update_bitmask_region>` **(** :ref:`Vector2<class_Vector2>` start=Vector2( 0, 0 ), :ref:`Vector2<class_Vector2>` end=Vector2( 0, 0 ) **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`update_dirty_quadrants<class_TileMap_method_update_dirty_quadrants>` **(** **)** |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`world_to_map<class_TileMap_method_world_to_map>` **(** :ref:`Vector2<class_Vector2>` world_position **)** |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Signals
-------
.. _class_TileMap_signal_settings_changed:
.. rst-class:: classref-signal
**settings_changed** **(** **)**
Emitted when a tilemap setting has changed.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumerations
------------
.. _enum_TileMap_Mode:
.. rst-class:: classref-enumeration
enum **Mode**:
.. _class_TileMap_constant_MODE_SQUARE:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_TileMap_Mode>` **MODE_SQUARE** = ``0``
Orthogonal orientation mode.
.. _class_TileMap_constant_MODE_ISOMETRIC:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_TileMap_Mode>` **MODE_ISOMETRIC** = ``1``
Isometric orientation mode.
.. _class_TileMap_constant_MODE_CUSTOM:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_TileMap_Mode>` **MODE_CUSTOM** = ``2``
Custom orientation mode.
.. rst-class:: classref-item-separator
----
.. _enum_TileMap_HalfOffset:
.. rst-class:: classref-enumeration
enum **HalfOffset**:
.. _class_TileMap_constant_HALF_OFFSET_X:
.. rst-class:: classref-enumeration-constant
:ref:`HalfOffset<enum_TileMap_HalfOffset>` **HALF_OFFSET_X** = ``0``
Half offset on the X coordinate.
.. _class_TileMap_constant_HALF_OFFSET_Y:
.. rst-class:: classref-enumeration-constant
:ref:`HalfOffset<enum_TileMap_HalfOffset>` **HALF_OFFSET_Y** = ``1``
Half offset on the Y coordinate.
.. _class_TileMap_constant_HALF_OFFSET_DISABLED:
.. rst-class:: classref-enumeration-constant
:ref:`HalfOffset<enum_TileMap_HalfOffset>` **HALF_OFFSET_DISABLED** = ``2``
Half offset disabled.
.. _class_TileMap_constant_HALF_OFFSET_NEGATIVE_X:
.. rst-class:: classref-enumeration-constant
:ref:`HalfOffset<enum_TileMap_HalfOffset>` **HALF_OFFSET_NEGATIVE_X** = ``3``
Half offset on the X coordinate (negative).
.. _class_TileMap_constant_HALF_OFFSET_NEGATIVE_Y:
.. rst-class:: classref-enumeration-constant
:ref:`HalfOffset<enum_TileMap_HalfOffset>` **HALF_OFFSET_NEGATIVE_Y** = ``4``
Half offset on the Y coordinate (negative).
.. rst-class:: classref-item-separator
----
.. _enum_TileMap_TileOrigin:
.. rst-class:: classref-enumeration
enum **TileOrigin**:
.. _class_TileMap_constant_TILE_ORIGIN_TOP_LEFT:
.. rst-class:: classref-enumeration-constant
:ref:`TileOrigin<enum_TileMap_TileOrigin>` **TILE_ORIGIN_TOP_LEFT** = ``0``
Tile origin at its top-left corner.
.. _class_TileMap_constant_TILE_ORIGIN_CENTER:
.. rst-class:: classref-enumeration-constant
:ref:`TileOrigin<enum_TileMap_TileOrigin>` **TILE_ORIGIN_CENTER** = ``1``
Tile origin at its center.
.. _class_TileMap_constant_TILE_ORIGIN_BOTTOM_LEFT:
.. rst-class:: classref-enumeration-constant
:ref:`TileOrigin<enum_TileMap_TileOrigin>` **TILE_ORIGIN_BOTTOM_LEFT** = ``2``
Tile origin at its bottom-left corner.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Constants
---------
.. _class_TileMap_constant_INVALID_CELL:
.. rst-class:: classref-constant
**INVALID_CELL** = ``-1``
Returned when a cell doesn't exist.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_TileMap_property_bake_navigation:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **bake_navigation** = ``false``
.. rst-class:: classref-property-setget
- void **set_bake_navigation** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_baking_navigation** **(** **)**
If ``true``, this TileMap bakes a navigation region.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_clip_uv:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **cell_clip_uv** = ``false``
.. rst-class:: classref-property-setget
- void **set_clip_uv** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **get_clip_uv** **(** **)**
If ``true``, the cell's UVs will be clipped.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_custom_transform:
.. rst-class:: classref-property
:ref:`Transform2D<class_Transform2D>` **cell_custom_transform** = ``Transform2D( 64, 0, 0, 64, 0, 0 )``
.. rst-class:: classref-property-setget
- void **set_custom_transform** **(** :ref:`Transform2D<class_Transform2D>` value **)**
- :ref:`Transform2D<class_Transform2D>` **get_custom_transform** **(** **)**
The custom :ref:`Transform2D<class_Transform2D>` to be applied to the TileMap's cells.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_half_offset:
.. rst-class:: classref-property
:ref:`HalfOffset<enum_TileMap_HalfOffset>` **cell_half_offset** = ``2``
.. rst-class:: classref-property-setget
- void **set_half_offset** **(** :ref:`HalfOffset<enum_TileMap_HalfOffset>` value **)**
- :ref:`HalfOffset<enum_TileMap_HalfOffset>` **get_half_offset** **(** **)**
Amount to offset alternating tiles. See :ref:`HalfOffset<enum_TileMap_HalfOffset>` for possible values.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_quadrant_size:
.. rst-class:: classref-property
:ref:`int<class_int>` **cell_quadrant_size** = ``16``
.. rst-class:: classref-property-setget
- void **set_quadrant_size** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_quadrant_size** **(** **)**
The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_size:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **cell_size** = ``Vector2( 64, 64 )``
.. rst-class:: classref-property-setget
- void **set_cell_size** **(** :ref:`Vector2<class_Vector2>` value **)**
- :ref:`Vector2<class_Vector2>` **get_cell_size** **(** **)**
The TileMap's cell size.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_tile_origin:
.. rst-class:: classref-property
:ref:`TileOrigin<enum_TileMap_TileOrigin>` **cell_tile_origin** = ``0``
.. rst-class:: classref-property-setget
- void **set_tile_origin** **(** :ref:`TileOrigin<enum_TileMap_TileOrigin>` value **)**
- :ref:`TileOrigin<enum_TileMap_TileOrigin>` **get_tile_origin** **(** **)**
Position for tile origin. See :ref:`TileOrigin<enum_TileMap_TileOrigin>` for possible values.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_cell_y_sort:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **cell_y_sort** = ``false``
.. rst-class:: classref-property-setget
- void **set_y_sort_mode** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_y_sort_mode_enabled** **(** **)**
If ``true``, the TileMap's direct children will be drawn in order of their Y coordinate.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_centered_textures:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **centered_textures** = ``false``
.. rst-class:: classref-property-setget
- void **set_centered_textures** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_centered_textures_enabled** **(** **)**
If ``true``, the textures will be centered in the middle of each tile. This is useful for certain isometric or top-down modes when textures are made larger or smaller than the tiles (e.g. to avoid flickering on tile edges). The offset is still applied, but from the center of the tile. If used, :ref:`compatibility_mode<class_TileMap_property_compatibility_mode>` is ignored.
If ``false``, the texture position start in the top-left corner unless :ref:`compatibility_mode<class_TileMap_property_compatibility_mode>` is enabled.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_collision_bounce:
.. rst-class:: classref-property
:ref:`float<class_float>` **collision_bounce** = ``0.0``
.. rst-class:: classref-property-setget
- void **set_collision_bounce** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_collision_bounce** **(** **)**
Bounce value for static body collisions (see ``collision_use_kinematic``).
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_collision_friction:
.. rst-class:: classref-property
:ref:`float<class_float>` **collision_friction** = ``1.0``
.. rst-class:: classref-property-setget
- void **set_collision_friction** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_collision_friction** **(** **)**
Friction value for static body collisions (see ``collision_use_kinematic``).
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_collision_layer:
.. rst-class:: classref-property
:ref:`int<class_int>` **collision_layer** = ``1``
.. rst-class:: classref-property-setget
- void **set_collision_layer** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_collision_layer** **(** **)**
The collision layer(s) for all colliders in the TileMap. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_collision_mask:
.. rst-class:: classref-property
:ref:`int<class_int>` **collision_mask** = ``1``
.. rst-class:: classref-property-setget
- void **set_collision_mask** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_collision_mask** **(** **)**
The collision mask(s) for all colliders in the TileMap. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_collision_use_kinematic:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **collision_use_kinematic** = ``false``
.. rst-class:: classref-property-setget
- void **set_collision_use_kinematic** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **get_collision_use_kinematic** **(** **)**
If ``true``, TileMap collisions will be handled as a kinematic body. If ``false``, collisions will be handled as static body.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_collision_use_parent:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **collision_use_parent** = ``false``
.. rst-class:: classref-property-setget
- void **set_collision_use_parent** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **get_collision_use_parent** **(** **)**
If ``true``, this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a :ref:`CollisionObject2D<class_CollisionObject2D>`.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_compatibility_mode:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **compatibility_mode** = ``false``
.. rst-class:: classref-property-setget
- void **set_compatibility_mode** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_compatibility_mode_enabled** **(** **)**
If ``true``, the compatibility with the tilemaps made in Godot 3.1 or earlier is maintained (textures move when the tile origin changes and rotate if the texture size is not homogeneous). This mode presents problems when doing ``flip_h``, ``flip_v`` and ``transpose`` tile operations on non-homogeneous isometric tiles (e.g. 2:1), in which the texture could not coincide with the collision, thus it is not recommended for isometric or non-square tiles.
If ``false``, the textures do not move when doing ``flip_h``, ``flip_v`` operations if no offset is used, nor when changing the tile origin.
The compatibility mode doesn't work with the :ref:`centered_textures<class_TileMap_property_centered_textures>` option, because displacing textures with the :ref:`cell_tile_origin<class_TileMap_property_cell_tile_origin>` option or in irregular tiles is not relevant when centering those textures.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_mode:
.. rst-class:: classref-property
:ref:`Mode<enum_TileMap_Mode>` **mode** = ``0``
.. rst-class:: classref-property-setget
- void **set_mode** **(** :ref:`Mode<enum_TileMap_Mode>` value **)**
- :ref:`Mode<enum_TileMap_Mode>` **get_mode** **(** **)**
The TileMap orientation mode. See :ref:`Mode<enum_TileMap_Mode>` for possible values.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_navigation_layers:
.. rst-class:: classref-property
:ref:`int<class_int>` **navigation_layers** = ``1``
.. rst-class:: classref-property-setget
- void **set_navigation_layers** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_navigation_layers** **(** **)**
The navigation layers the TileMap generates its navigation regions in.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_occluder_light_mask:
.. rst-class:: classref-property
:ref:`int<class_int>` **occluder_light_mask** = ``1``
.. rst-class:: classref-property-setget
- void **set_occluder_light_mask** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_occluder_light_mask** **(** **)**
The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s).
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_show_collision:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **show_collision** = ``false``
.. rst-class:: classref-property-setget
- void **set_show_collision** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_show_collision_enabled** **(** **)**
If ``true``, collision shapes are visible in the editor. Doesn't affect collision shapes visibility at runtime. To show collision shapes at runtime, enable **Visible Collision Shapes** in the **Debug** menu instead.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_property_tile_set:
.. rst-class:: classref-property
:ref:`TileSet<class_TileSet>` **tile_set**
.. rst-class:: classref-property-setget
- void **set_tileset** **(** :ref:`TileSet<class_TileSet>` value **)**
- :ref:`TileSet<class_TileSet>` **get_tileset** **(** **)**
The assigned :ref:`TileSet<class_TileSet>`.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_TileMap_method_clear:
.. rst-class:: classref-method
void **clear** **(** **)**
Clears all cells.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_fix_invalid_tiles:
.. rst-class:: classref-method
void **fix_invalid_tiles** **(** **)**
Clears cells that do not exist in the tileset.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_cell:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_cell** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const|
Returns the tile index of the given cell. If no tile exists in the cell, returns :ref:`INVALID_CELL<class_TileMap_constant_INVALID_CELL>`.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_cell_autotile_coord:
.. rst-class:: classref-method
:ref:`Vector2<class_Vector2>` **get_cell_autotile_coord** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const|
Returns the coordinate (subtile column and row) of the autotile variation in the tileset. Returns a zero vector if the cell doesn't have autotiling.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_cellv:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_cellv** **(** :ref:`Vector2<class_Vector2>` position **)** |const|
Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns :ref:`INVALID_CELL<class_TileMap_constant_INVALID_CELL>`.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_collision_layer_bit:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** |const|
Returns ``true`` if the given collision layer bit is set.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_collision_mask_bit:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** |const|
Returns ``true`` if the given collision mask bit is set.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_used_cells:
.. rst-class:: classref-method
:ref:`Array<class_Array>` **get_used_cells** **(** **)** |const|
Returns a :ref:`Vector2<class_Vector2>` array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from ``-1``).
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_used_cells_by_id:
.. rst-class:: classref-method
:ref:`Array<class_Array>` **get_used_cells_by_id** **(** :ref:`int<class_int>` id **)** |const|
Returns an array of all cells with the given tile index specified in ``id``.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_get_used_rect:
.. rst-class:: classref-method
:ref:`Rect2<class_Rect2>` **get_used_rect** **(** **)**
Returns a rectangle enclosing the used (non-empty) tiles of the map.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_is_cell_transposed:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_cell_transposed** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const|
Returns ``true`` if the given cell is transposed, i.e. the X and Y axes are swapped.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_is_cell_x_flipped:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_cell_x_flipped** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const|
Returns ``true`` if the given cell is flipped in the X axis.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_is_cell_y_flipped:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_cell_y_flipped** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** |const|
Returns ``true`` if the given cell is flipped in the Y axis.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_map_to_world:
.. rst-class:: classref-method
:ref:`Vector2<class_Vector2>` **map_to_world** **(** :ref:`Vector2<class_Vector2>` map_position, :ref:`bool<class_bool>` ignore_half_ofs=false **)** |const|
Returns the local position of the top left corner of the cell corresponding to the given tilemap (grid-based) coordinates.
To get the global position, use :ref:`Node2D.to_global<class_Node2D_method_to_global>`:
::
var local_position = my_tilemap.map_to_world(map_position)
var global_position = my_tilemap.to_global(local_position)
Optionally, the tilemap's half offset can be ignored.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_set_cell:
.. rst-class:: classref-method
void **set_cell** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false, :ref:`Vector2<class_Vector2>` autotile_coord=Vector2( 0, 0 ) **)**
Sets the tile index for the given cell.
An index of ``-1`` clears the cell.
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
\ **Note:** Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call :ref:`update_dirty_quadrants<class_TileMap_method_update_dirty_quadrants>`.
Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed:
::
func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2()):
# Write your custom logic here.
# To call the default method:
.set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord)
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_set_cellv:
.. rst-class:: classref-method
void **set_cellv** **(** :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` tile, :ref:`bool<class_bool>` flip_x=false, :ref:`bool<class_bool>` flip_y=false, :ref:`bool<class_bool>` transpose=false, :ref:`Vector2<class_Vector2>` autotile_coord=Vector2( 0, 0 ) **)**
Sets the tile index for the cell given by a Vector2.
An index of ``-1`` clears the cell.
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
\ **Note:** Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call :ref:`update_dirty_quadrants<class_TileMap_method_update_dirty_quadrants>`.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_set_collision_layer_bit:
.. rst-class:: classref-method
void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
Sets the given collision layer bit.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_set_collision_mask_bit:
.. rst-class:: classref-method
void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
Sets the given collision mask bit.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_update_bitmask_area:
.. rst-class:: classref-method
void **update_bitmask_area** **(** :ref:`Vector2<class_Vector2>` position **)**
Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_update_bitmask_region:
.. rst-class:: classref-method
void **update_bitmask_region** **(** :ref:`Vector2<class_Vector2>` start=Vector2( 0, 0 ), :ref:`Vector2<class_Vector2>` end=Vector2( 0, 0 ) **)**
Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates).
Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_update_dirty_quadrants:
.. rst-class:: classref-method
void **update_dirty_quadrants** **(** **)**
Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.
.. rst-class:: classref-item-separator
----
.. _class_TileMap_method_world_to_map:
.. rst-class:: classref-method
:ref:`Vector2<class_Vector2>` **world_to_map** **(** :ref:`Vector2<class_Vector2>` world_position **)** |const|
Returns the tilemap (grid-based) coordinates corresponding to the given local position.
To use this with a global position, first determine the local position with :ref:`Node2D.to_local<class_Node2D_method_to_local>`:
::
var local_position = my_tilemap.to_local(global_position)
var map_position = my_tilemap.world_to_map(local_position)
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`