2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2021-04-26 11:14:51 +00:00
<class name= "TileMap" inherits= "Node2D" version= "3.4" >
2017-09-12 20:42:36 +00:00
<brief_description >
Node for 2D tile-based maps.
</brief_description>
<description >
Node for 2D tile-based maps. Tilemaps use a [TileSet] which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps.
2021-01-22 18:03:09 +00:00
When doing physics queries against the tilemap, the cell coordinates are encoded as [code]metadata[/code] for each detected collision shape returned by methods such as [method Physics2DDirectSpaceState.intersect_shape], [method Physics2DDirectBodyState.get_contact_collider_shape_metadata], etc.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2021-08-12 14:58:38 +00:00
<link title= "Using Tilemaps" > https://docs.godotengine.org/en/3.4/tutorials/2d/using_tilemaps.html</link>
2020-10-01 08:34:47 +00:00
<link title= "2D Platformer Demo" > https://godotengine.org/asset-library/asset/120</link>
<link title= "2D Isometric Demo" > https://godotengine.org/asset-library/asset/112</link>
<link title= "2D Hexagonal Demo" > https://godotengine.org/asset-library/asset/111</link>
<link title= "2D Navigation Astar Demo" > https://godotengine.org/asset-library/asset/519</link>
<link title= "2D Role Playing Game Demo" > https://godotengine.org/asset-library/asset/520</link>
<link title= "2D Kinematic Character Demo" > https://godotengine.org/asset-library/asset/113</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
<method name= "clear" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-13 00:58:45 +00:00
Clears all cells.
2017-09-12 20:42:36 +00:00
</description>
</method>
2018-02-24 05:56:48 +00:00
<method name= "fix_invalid_tiles" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2018-02-24 05:56:48 +00:00
<description >
2018-05-13 00:58:45 +00:00
Clears cells that do not exist in the tileset.
2018-02-24 05:56:48 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_cell" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "x" type= "int" />
<argument index= "1" name= "y" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-02-13 04:44:39 +00:00
Returns the tile index of the given cell. If no tile exists in the cell, returns [constant INVALID_CELL].
2017-09-12 20:42:36 +00:00
</description>
</method>
2018-12-27 10:10:09 +00:00
<method name= "get_cell_autotile_coord" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
<argument index= "0" name= "x" type= "int" />
<argument index= "1" name= "y" type= "int" />
2018-12-27 10:10:09 +00:00
<description >
2020-04-03 22:40:31 +00:00
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.
2018-12-27 10:10:09 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_cellv" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "position" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
2019-02-13 04:44:39 +00:00
Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns [constant INVALID_CELL].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_collision_layer_bit" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "bit" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-28 12:53:15 +00:00
Returns [code]true[/code] if the given collision layer bit is set.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_collision_mask_bit" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "bit" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-28 12:53:15 +00:00
Returns [code]true[/code] if the given collision mask bit is set.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_used_cells" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
2017-09-12 20:42:36 +00:00
<description >
2018-08-03 18:38:31 +00:00
Returns a [Vector2] array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from [code]-1[/code]).
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_used_cells_by_id" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
<argument index= "0" name= "id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2020-05-12 07:26:38 +00:00
Returns an array of all cells with the given tile index specified in [code]id[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_used_rect" >
2021-07-30 13:28:05 +00:00
<return type= "Rect2" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-28 12:53:15 +00:00
Returns a rectangle enclosing the used (non-empty) tiles of the map.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_cell_transposed" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "x" type= "int" />
<argument index= "1" name= "y" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Returns [code]true[/code] if the given cell is transposed, i.e. the X and Y axes are swapped.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_cell_x_flipped" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "x" type= "int" />
<argument index= "1" name= "y" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Returns [code]true[/code] if the given cell is flipped in the X axis.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_cell_y_flipped" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "x" type= "int" />
<argument index= "1" name= "y" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Returns [code]true[/code] if the given cell is flipped in the Y axis.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "map_to_world" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
<argument index= "0" name= "map_position" type= "Vector2" />
<argument index= "1" name= "ignore_half_ofs" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2021-02-12 10:20:35 +00:00
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 [method Node2D.to_global]:
[codeblock]
var local_position = my_tilemap.map_to_world(map_position)
var global_position = my_tilemap.to_global(local_position)
[/codeblock]
2018-05-13 00:58:45 +00:00
Optionally, the tilemap's half offset can be ignored.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_cell" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "x" type= "int" />
<argument index= "1" name= "y" type= "int" />
<argument index= "2" name= "tile" type= "int" />
<argument index= "3" name= "flip_x" type= "bool" default= "false" />
<argument index= "4" name= "flip_y" type= "bool" default= "false" />
<argument index= "5" name= "transpose" type= "bool" default= "false" />
<argument index= "6" name= "autotile_coord" type= "Vector2" default= "Vector2( 0, 0 )" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-13 00:58:45 +00:00
Sets the tile index for the cell given by a Vector2.
An index of [code]-1[/code] clears the cell.
2020-04-03 22:40:31 +00:00
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
2019-06-21 23:04:47 +00:00
[b]Note:[/b] Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
2018-07-22 13:26:14 +00:00
If you need these to be immediately updated, you can call [method update_dirty_quadrants].
2019-04-05 13:27:38 +00:00
Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed:
[codeblock]
2021-04-05 09:13:25 +00:00
func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2()):
2019-04-05 13:27:38 +00:00
# Write your custom logic here.
# To call the default method:
.set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord)
2019-04-15 12:49:41 +00:00
[/codeblock]
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_cellv" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "position" type= "Vector2" />
<argument index= "1" name= "tile" type= "int" />
<argument index= "2" name= "flip_x" type= "bool" default= "false" />
<argument index= "3" name= "flip_y" type= "bool" default= "false" />
<argument index= "4" name= "transpose" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-13 00:58:45 +00:00
Sets the tile index for the given cell.
An index of [code]-1[/code] clears the cell.
Optionally, the tile can also be flipped or transposed.
2019-06-21 23:04:47 +00:00
[b]Note:[/b] Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
2018-07-22 13:26:14 +00:00
If you need these to be immediately updated, you can call [method update_dirty_quadrants].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_collision_layer_bit" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "bit" type= "int" />
<argument index= "1" name= "value" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-13 00:58:45 +00:00
Sets the given collision layer bit.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_collision_mask_bit" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "bit" type= "int" />
<argument index= "1" name= "value" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-28 12:53:15 +00:00
Sets the given collision mask bit.
2017-09-12 20:42:36 +00:00
</description>
</method>
2017-12-16 19:34:16 +00:00
<method name= "update_bitmask_area" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "position" type= "Vector2" />
2017-12-16 19:34:16 +00:00
<description >
2019-06-21 23:04:47 +00:00
Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.
2017-12-16 19:34:16 +00:00
</description>
</method>
<method name= "update_bitmask_region" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "start" type= "Vector2" default= "Vector2( 0, 0 )" />
<argument index= "1" name= "end" type= "Vector2" default= "Vector2( 0, 0 )" />
2017-12-16 19:34:16 +00:00
<description >
2019-06-21 23:04:47 +00:00
Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates).
2018-05-13 00:58:45 +00:00
Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap.
2017-12-16 19:34:16 +00:00
</description>
</method>
2018-07-22 13:26:14 +00:00
<method name= "update_dirty_quadrants" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2018-07-22 13:26:14 +00:00
<description >
Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "world_to_map" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
<argument index= "0" name= "world_position" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
2019-01-19 14:23:49 +00:00
Returns the tilemap (grid-based) coordinates corresponding to the given local position.
2021-02-12 10:20:35 +00:00
To use this with a global position, first determine the local position with [method Node2D.to_local]:
[codeblock]
var local_position = my_tilemap.to_local(global_position)
var map_position = my_tilemap.world_to_map(local_position)
[/codeblock]
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2019-06-29 10:38:01 +00:00
<member name= "cell_clip_uv" type= "bool" setter= "set_clip_uv" getter= "get_clip_uv" default= "false" >
2019-11-02 10:49:40 +00:00
If [code]true[/code], the cell's UVs will be clipped.
2017-11-13 08:24:36 +00:00
</member>
2019-09-24 09:44:48 +00:00
<member name= "cell_custom_transform" type= "Transform2D" setter= "set_custom_transform" getter= "get_custom_transform" default= "Transform2D( 64, 0, 0, 64, 0, 0 )" >
2017-09-12 20:42:36 +00:00
The custom [Transform2D] to be applied to the TileMap's cells.
</member>
2019-06-29 10:38:01 +00:00
<member name= "cell_half_offset" type= "int" setter= "set_half_offset" getter= "get_half_offset" enum= "TileMap.HalfOffset" default= "2" >
2019-06-29 13:24:23 +00:00
Amount to offset alternating tiles. See [enum HalfOffset] for possible values.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "cell_quadrant_size" type= "int" setter= "set_quadrant_size" getter= "get_quadrant_size" default= "16" >
2019-06-29 13:24:23 +00:00
The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "cell_size" type= "Vector2" setter= "set_cell_size" getter= "get_cell_size" default= "Vector2( 64, 64 )" >
2017-09-12 20:42:36 +00:00
The TileMap's cell size.
</member>
2019-06-29 10:38:01 +00:00
<member name= "cell_tile_origin" type= "int" setter= "set_tile_origin" getter= "get_tile_origin" enum= "TileMap.TileOrigin" default= "0" >
2019-06-29 13:24:23 +00:00
Position for tile origin. See [enum TileOrigin] for possible values.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "cell_y_sort" type= "bool" setter= "set_y_sort_mode" getter= "is_y_sort_mode_enabled" default= "false" >
2020-10-26 23:30:14 +00:00
If [code]true[/code], the TileMap's direct children will be drawn in order of their Y coordinate.
2017-09-12 20:42:36 +00:00
</member>
2019-07-04 10:15:49 +00:00
<member name= "centered_textures" type= "bool" setter= "set_centered_textures" getter= "is_centered_textures_enabled" default= "false" >
2019-07-01 20:43:52 +00:00
If [code]true[/code], 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, [member compatibility_mode] is ignored.
If [code]false[/code], the texture position start in the top-left corner unless [member compatibility_mode] is enabled.
</member>
2019-06-29 10:38:01 +00:00
<member name= "collision_bounce" type= "float" setter= "set_collision_bounce" getter= "get_collision_bounce" default= "0.0" >
2019-06-29 13:24:23 +00:00
Bounce value for static body collisions (see [code]collision_use_kinematic[/code]).
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "collision_friction" type= "float" setter= "set_collision_friction" getter= "get_collision_friction" default= "1.0" >
2019-06-29 13:24:23 +00:00
Friction value for static body collisions (see [code]collision_use_kinematic[/code]).
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "collision_layer" type= "int" setter= "set_collision_layer" getter= "get_collision_layer" default= "1" >
2021-08-12 14:58:38 +00:00
The collision layer(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/3.4/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "collision_mask" type= "int" setter= "set_collision_mask" getter= "get_collision_mask" default= "1" >
2021-08-12 14:58:38 +00:00
The collision mask(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/3.4/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 19:45:14 +00:00
<member name= "collision_use_kinematic" type= "bool" setter= "set_collision_use_kinematic" getter= "get_collision_use_kinematic" default= "false" >
2019-06-29 13:24:23 +00:00
If [code]true[/code], TileMap collisions will be handled as a kinematic body. If [code]false[/code], collisions will be handled as static body.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 19:22:15 +00:00
<member name= "collision_use_parent" type= "bool" setter= "set_collision_use_parent" getter= "get_collision_use_parent" default= "false" >
2019-11-02 10:49:40 +00:00
If [code]true[/code], this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a [CollisionObject2D].
2019-06-29 19:22:15 +00:00
</member>
2019-07-04 10:15:49 +00:00
<member name= "compatibility_mode" type= "bool" setter= "set_compatibility_mode" getter= "is_compatibility_mode_enabled" default= "false" >
If [code]true[/code], 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 [code]flip_h[/code], [code]flip_v[/code] and [code]transpose[/code] 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 [code]false[/code], the textures do not move when doing [code]flip_h[/code], [code]flip_v[/code] operations if no offset is used, nor when changing the tile origin.
The compatibility mode doesn't work with the [member centered_textures] option, because displacing textures with the [member cell_tile_origin] option or in irregular tiles is not relevant when centering those textures.
</member>
2019-06-29 10:38:01 +00:00
<member name= "mode" type= "int" setter= "set_mode" getter= "get_mode" enum= "TileMap.Mode" default= "0" >
2019-06-29 13:24:23 +00:00
The TileMap orientation mode. See [enum Mode] for possible values.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "occluder_light_mask" type= "int" setter= "set_occluder_light_mask" getter= "get_occluder_light_mask" default= "1" >
2018-09-22 21:50:45 +00:00
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).
2017-09-12 20:42:36 +00:00
</member>
2021-03-26 10:18:05 +00:00
<member name= "show_collision" type= "bool" setter= "set_show_collision" getter= "is_show_collision_enabled" default= "false" >
2021-05-25 18:44:43 +00:00
If [code]true[/code], collision shapes are visible in the editor. Doesn't affect collision shapes visibility at runtime. To show collision shapes at runtime, enable [b]Visible Collision Shapes[/b] in the [b]Debug[/b] menu instead.
2020-03-22 11:20:40 +00:00
</member>
2019-07-15 18:42:47 +00:00
<member name= "tile_set" type= "TileSet" setter= "set_tileset" getter= "get_tileset" >
2017-09-12 20:42:36 +00:00
The assigned [TileSet].
</member>
</members>
<signals >
<signal name= "settings_changed" >
<description >
Emitted when a tilemap setting has changed.
</description>
</signal>
</signals>
<constants >
2017-11-24 22:16:30 +00:00
<constant name= "INVALID_CELL" value= "-1" >
2017-09-12 20:42:36 +00:00
Returned when a cell doesn't exist.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "MODE_SQUARE" value= "0" enum= "Mode" >
2017-09-12 20:42:36 +00:00
Orthogonal orientation mode.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "MODE_ISOMETRIC" value= "1" enum= "Mode" >
2017-09-12 20:42:36 +00:00
Isometric orientation mode.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "MODE_CUSTOM" value= "2" enum= "Mode" >
2017-09-12 20:42:36 +00:00
Custom orientation mode.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "HALF_OFFSET_X" value= "0" enum= "HalfOffset" >
2017-09-12 20:42:36 +00:00
Half offset on the X coordinate.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "HALF_OFFSET_Y" value= "1" enum= "HalfOffset" >
2017-09-12 20:42:36 +00:00
Half offset on the Y coordinate.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "HALF_OFFSET_DISABLED" value= "2" enum= "HalfOffset" >
2017-09-12 20:42:36 +00:00
Half offset disabled.
</constant>
2019-03-23 23:59:24 +00:00
<constant name= "HALF_OFFSET_NEGATIVE_X" value= "3" enum= "HalfOffset" >
Half offset on the X coordinate (negative).
</constant>
<constant name= "HALF_OFFSET_NEGATIVE_Y" value= "4" enum= "HalfOffset" >
Half offset on the Y coordinate (negative).
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "TILE_ORIGIN_TOP_LEFT" value= "0" enum= "TileOrigin" >
2017-09-12 20:42:36 +00:00
Tile origin at its top-left corner.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "TILE_ORIGIN_CENTER" value= "1" enum= "TileOrigin" >
2017-09-12 20:42:36 +00:00
Tile origin at its center.
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "TILE_ORIGIN_BOTTOM_LEFT" value= "2" enum= "TileOrigin" >
2018-04-17 14:18:57 +00:00
Tile origin at its bottom-left corner.
2017-09-12 20:42:36 +00:00
</constant>
</constants>
</class>