mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
462 lines
33 KiB
ReStructuredText
462 lines
33 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the TileMap.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_TileMap:
|
|
|
|
TileMap
|
|
=======
|
|
|
|
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
Node for 2D tile-based maps.
|
|
|
|
Description
|
|
-----------
|
|
|
|
Node for 2D tile-based maps. Tilemaps use a :ref:`TileSet<class_TileSet>` which contain a list of tiles which are used to create grid-based maps. A TileMap may have several layers, layouting tiles on top of each other.
|
|
|
|
Tutorials
|
|
---------
|
|
|
|
- :doc:`../tutorials/2d/using_tilemaps`
|
|
|
|
- `2D Platformer Demo <https://godotengine.org/asset-library/asset/120>`__
|
|
|
|
- `2D Isometric Demo <https://godotengine.org/asset-library/asset/112>`__
|
|
|
|
- `2D Hexagonal Demo <https://godotengine.org/asset-library/asset/111>`__
|
|
|
|
- `2D Navigation Astar Demo <https://godotengine.org/asset-library/asset/519>`__
|
|
|
|
- `2D Role Playing Game Demo <https://godotengine.org/asset-library/asset/520>`__
|
|
|
|
- `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/113>`__
|
|
|
|
Properties
|
|
----------
|
|
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`int<class_int>` | :ref:`cell_quadrant_size<class_TileMap_property_cell_quadrant_size>` | ``16`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`bool<class_bool>` | :ref:`collision_animatable<class_TileMap_property_collision_animatable>` | ``false`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`collision_visibility_mode<class_TileMap_property_collision_visibility_mode>` | ``0`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`navigation_visibility_mode<class_TileMap_property_navigation_visibility_mode>` | ``0`` |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
| :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` | |
|
|
+----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`add_layer<class_TileMap_method_add_layer>` **(** :ref:`int<class_int>` to_position **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`clear<class_TileMap_method_clear>` **(** **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`clear_layer<class_TileMap_method_clear_layer>` **(** :ref:`int<class_int>` layer **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>` **(** **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_cell_alternative_tile<class_TileMap_method_get_cell_alternative_tile>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_cell_atlas_coords<class_TileMap_method_get_cell_atlas_coords>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_cell_source_id<class_TileMap_method_get_cell_source_id>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_coords_for_body_rid<class_TileMap_method_get_coords_for_body_rid>` **(** :ref:`RID<class_RID>` body **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_layer_name<class_TileMap_method_get_layer_name>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_layer_y_sort_origin<class_TileMap_method_get_layer_y_sort_origin>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_layer_z_index<class_TileMap_method_get_layer_z_index>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_layers_count<class_TileMap_method_get_layers_count>` **(** **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_neighbor_cell<class_TileMap_method_get_neighbor_cell>` **(** :ref:`Vector2i<class_Vector2i>` coords, :ref:`CellNeighbor<enum_TileSet_CellNeighbor>` neighbor **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_surrounding_tiles<class_TileMap_method_get_surrounding_tiles>` **(** :ref:`Vector2i<class_Vector2i>` coords **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_used_cells<class_TileMap_method_get_used_cells>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>` **(** **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_layer_enabled<class_TileMap_method_is_layer_enabled>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_layer_y_sort_enabled<class_TileMap_method_is_layer_y_sort_enabled>` **(** :ref:`int<class_int>` layer **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`map_to_world<class_TileMap_method_map_to_world>` **(** :ref:`Vector2i<class_Vector2i>` map_position **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`move_layer<class_TileMap_method_move_layer>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` to_position **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`remove_layer<class_TileMap_method_remove_layer>` **(** :ref:`int<class_int>` layer **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_cell<class_TileMap_method_set_cell>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=-1 **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_enabled<class_TileMap_method_set_layer_enabled>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_name<class_TileMap_method_set_layer_name>` **(** :ref:`int<class_int>` layer, :ref:`String<class_String>` name **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_y_sort_enabled<class_TileMap_method_set_layer_y_sort_enabled>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` y_sort_enabled **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_y_sort_origin<class_TileMap_method_set_layer_y_sort_origin>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` y_sort_origin **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_layer_z_index<class_TileMap_method_set_layer_z_index>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` z_index **)** |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2i<class_Vector2i>` | :ref:`world_to_map<class_TileMap_method_world_to_map>` **(** :ref:`Vector2<class_Vector2>` world_position **)** |const| |
|
|
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_TileMap_signal_changed:
|
|
|
|
- **changed** **(** **)**
|
|
|
|
Emitted when the :ref:`TileSet<class_TileSet>` of this TileMap changes.
|
|
|
|
Enumerations
|
|
------------
|
|
|
|
.. _enum_TileMap_VisibilityMode:
|
|
|
|
.. _class_TileMap_constant_VISIBILITY_MODE_DEFAULT:
|
|
|
|
.. _class_TileMap_constant_VISIBILITY_MODE_FORCE_HIDE:
|
|
|
|
.. _class_TileMap_constant_VISIBILITY_MODE_FORCE_SHOW:
|
|
|
|
enum **VisibilityMode**:
|
|
|
|
- **VISIBILITY_MODE_DEFAULT** = **0** --- Use the debug settings to determine visibility.
|
|
|
|
- **VISIBILITY_MODE_FORCE_HIDE** = **2** --- Always hide.
|
|
|
|
- **VISIBILITY_MODE_FORCE_SHOW** = **1** --- Always show.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_TileMap_property_cell_quadrant_size:
|
|
|
|
- :ref:`int<class_int>` **cell_quadrant_size**
|
|
|
|
+-----------+--------------------------+
|
|
| *Default* | ``16`` |
|
|
+-----------+--------------------------+
|
|
| *Setter* | set_quadrant_size(value) |
|
|
+-----------+--------------------------+
|
|
| *Getter* | get_quadrant_size() |
|
|
+-----------+--------------------------+
|
|
|
|
The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_property_collision_animatable:
|
|
|
|
- :ref:`bool<class_bool>` **collision_animatable**
|
|
|
|
+-----------+---------------------------------+
|
|
| *Default* | ``false`` |
|
|
+-----------+---------------------------------+
|
|
| *Setter* | set_collision_animatable(value) |
|
|
+-----------+---------------------------------+
|
|
| *Getter* | is_collision_animatable() |
|
|
+-----------+---------------------------------+
|
|
|
|
If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform.
|
|
|
|
**Note:** Enabling ``collision_animatable`` may have a small performance impact, only do it if the TileMap is moving and has colliding tiles.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_property_collision_visibility_mode:
|
|
|
|
- :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **collision_visibility_mode**
|
|
|
|
+-----------+--------------------------------------+
|
|
| *Default* | ``0`` |
|
|
+-----------+--------------------------------------+
|
|
| *Setter* | set_collision_visibility_mode(value) |
|
|
+-----------+--------------------------------------+
|
|
| *Getter* | get_collision_visibility_mode() |
|
|
+-----------+--------------------------------------+
|
|
|
|
Show or hide the TileMap's collision shapes. If set to ``VISIBILITY_MODE_DEFAULT``, this depends on the show collision debug settings.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_property_navigation_visibility_mode:
|
|
|
|
- :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **navigation_visibility_mode**
|
|
|
|
+-----------+---------------------------------------+
|
|
| *Default* | ``0`` |
|
|
+-----------+---------------------------------------+
|
|
| *Setter* | set_navigation_visibility_mode(value) |
|
|
+-----------+---------------------------------------+
|
|
| *Getter* | get_navigation_visibility_mode() |
|
|
+-----------+---------------------------------------+
|
|
|
|
Show or hide the TileMap's collision shapes. If set to ``VISIBILITY_MODE_DEFAULT``, this depends on the show navigation debug settings.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_property_tile_set:
|
|
|
|
- :ref:`TileSet<class_TileSet>` **tile_set**
|
|
|
|
+----------+--------------------+
|
|
| *Setter* | set_tileset(value) |
|
|
+----------+--------------------+
|
|
| *Getter* | get_tileset() |
|
|
+----------+--------------------+
|
|
|
|
The assigned :ref:`TileSet<class_TileSet>`.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_TileMap_method_add_layer:
|
|
|
|
- void **add_layer** **(** :ref:`int<class_int>` to_position **)**
|
|
|
|
Adds a layer at the given position ``to_position`` in the array. If ``to_position`` is -1, adds it at the end of the array.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_clear:
|
|
|
|
- void **clear** **(** **)**
|
|
|
|
Clears all cells.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_clear_layer:
|
|
|
|
- void **clear_layer** **(** :ref:`int<class_int>` layer **)**
|
|
|
|
Clears all cells on the given layer.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_fix_invalid_tiles:
|
|
|
|
- void **fix_invalid_tiles** **(** **)**
|
|
|
|
Clears cells that do not exist in the tileset.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_cell_alternative_tile:
|
|
|
|
- :ref:`int<class_int>` **get_cell_alternative_tile** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const|
|
|
|
|
Returns the tile alternative ID of the cell on layer ``layer`` at ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_cell_atlas_coords:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **get_cell_atlas_coords** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const|
|
|
|
|
Returns the tile atlas coordinates ID of the cell on layer ``layer`` at coordinates ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_cell_source_id:
|
|
|
|
- :ref:`int<class_int>` **get_cell_source_id** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies **)** |const|
|
|
|
|
Returns the tile source ID of the cell on layer ``layer`` at coordinates ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_coords_for_body_rid:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **get_coords_for_body_rid** **(** :ref:`RID<class_RID>` body **)**
|
|
|
|
Returns the coodinates of the tile for given physics body RID. Such RID can be retrieved from :ref:`KinematicCollision2D.get_collider_rid<class_KinematicCollision2D_method_get_collider_rid>`, when colliding with a tile.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_name:
|
|
|
|
- :ref:`String<class_String>` **get_layer_name** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's name.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_y_sort_origin:
|
|
|
|
- :ref:`int<class_int>` **get_layer_y_sort_origin** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's Y sort origin.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layer_z_index:
|
|
|
|
- :ref:`int<class_int>` **get_layer_z_index** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a TileMap layer's Z-index value.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_layers_count:
|
|
|
|
- :ref:`int<class_int>` **get_layers_count** **(** **)** |const|
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_neighbor_cell:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **get_neighbor_cell** **(** :ref:`Vector2i<class_Vector2i>` coords, :ref:`CellNeighbor<enum_TileSet_CellNeighbor>` neighbor **)** |const|
|
|
|
|
Returns the neighboring cell to the one at coordinates ``coords``, indentified by the ``neighbor`` direction. This method takes into account the different layouts a TileMap can take.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_surrounding_tiles:
|
|
|
|
- :ref:`Vector2i[]<class_Vector2i>` **get_surrounding_tiles** **(** :ref:`Vector2i<class_Vector2i>` coords **)**
|
|
|
|
Returns the list of all neighbourings cells to the one at ``coords``
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_used_cells:
|
|
|
|
- :ref:`Vector2i[]<class_Vector2i>` **get_used_cells** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns a :ref:`Vector2<class_Vector2>` array with the positions of all cells containing a tile in the given layer. A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers is ``Vector2(-1, -1)`` and its alternative identifier is -1.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_get_used_rect:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **get_used_rect** **(** **)**
|
|
|
|
Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_is_layer_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_layer_enabled** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns if a layer is enabled.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_is_layer_y_sort_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_layer_y_sort_enabled** **(** :ref:`int<class_int>` layer **)** |const|
|
|
|
|
Returns if a layer Y-sorts its tiles.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_map_to_world:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **map_to_world** **(** :ref:`Vector2i<class_Vector2i>` map_position **)** |const|
|
|
|
|
Returns the local position corresponding to the given tilemap (grid-based) coordinates.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_move_layer:
|
|
|
|
- void **move_layer** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` to_position **)**
|
|
|
|
Moves the layer at index ``layer_index`` to the given position ``to_position`` in the array.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_remove_layer:
|
|
|
|
- void **remove_layer** **(** :ref:`int<class_int>` layer **)**
|
|
|
|
Moves the layer at index ``layer_index`` to the given position ``to_position`` in the array.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_cell:
|
|
|
|
- void **set_cell** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=-1 **)**
|
|
|
|
Sets the tile indentifiers for the cell on layer ``layer`` at coordinates ``coords``. Each tile of the :ref:`TileSet<class_TileSet>` is identified using three parts:
|
|
|
|
- The source indentifier ``source_id`` identifies a :ref:`TileSetSource<class_TileSetSource>` identifier. See :ref:`TileSet.set_source_id<class_TileSet_method_set_source_id>`,
|
|
|
|
- The atlas coordinates identifier ``atlas_coords`` identifies a tile coordinates in the atlas (if the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`. For :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>` it should be 0),
|
|
|
|
- The alternative tile identifier ``alternative_tile`` identifies a tile alternative the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`, and the scene for a :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>`.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_layer_enabled:
|
|
|
|
- void **set_layer_enabled** **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)**
|
|
|
|
Enables or disables the layer ``layer``. A disabled layer is not processed at all (no rendering, no physics, etc...).
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_layer_name:
|
|
|
|
- void **set_layer_name** **(** :ref:`int<class_int>` layer, :ref:`String<class_String>` name **)**
|
|
|
|
Sets a layer's name. This is mostly useful in the editor.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_layer_y_sort_enabled:
|
|
|
|
- void **set_layer_y_sort_enabled** **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` y_sort_enabled **)**
|
|
|
|
Enables or disables a layer's Y-sorting. If a layer is Y-sorted, the layer will behave as a CanvasItem node where each of its tile gets Y-sorted.
|
|
|
|
Y-sorted layers should usually be on different Z-index values than not Y-sorted layers, otherwise, each of those layer will be Y-sorted as whole with the Y-sorted one. This is usually an undesired behvaior.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_layer_y_sort_origin:
|
|
|
|
- void **set_layer_y_sort_origin** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` y_sort_origin **)**
|
|
|
|
Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value.
|
|
|
|
This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_set_layer_z_index:
|
|
|
|
- void **set_layer_z_index** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` z_index **)**
|
|
|
|
Sets a layers Z-index value. This Z-index is added to each tile's Z-index value.
|
|
|
|
----
|
|
|
|
.. _class_TileMap_method_world_to_map:
|
|
|
|
- :ref:`Vector2i<class_Vector2i>` **world_to_map** **(** :ref:`Vector2<class_Vector2>` world_position **)** |const|
|
|
|
|
Returns the tilemap (grid-based) coordinates corresponding to the given local position.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
|
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
|
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|