2021-05-07 13:41:39 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-02-14 13:18:53 +00:00
<class name= "TileSetAtlasSource" inherits= "TileSetSource" version= "4.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2021-05-07 13:41:39 +00:00
<brief_description >
2021-09-06 09:56:31 +00:00
Exposes a 2D atlas texture as a set of tiles for a [TileSet] resource.
2021-05-07 13:41:39 +00:00
</brief_description>
<description >
2021-09-06 09:56:31 +00:00
An atlas is a grid of tiles laid out on a texture. Each tile in the grid must be exposed using [method create_tile]. Those tiles are then indexed using their coordinates in the grid.
Each tile can also have a size in the grid coordinates, making it more or less cells in the atlas.
Alternatives version of a tile can be created using [method create_alternative_tile], which are then indexed using an alternative ID. The main tile (the one in the grid), is accessed with an alternative ID equal to 0.
Each tile alternate has a set of properties that is defined by the source's [TileSet] layers. Those properties are stored in a TileData object that can be accessed and modified using [method get_tile_data].
As TileData properties are stored directly in the TileSetAtlasSource resource, their properties might also be set using [code]TileSetAtlasSource.set("< coords_x> :< coords_y> /< alternative_id> /< tile_data_property> ")[/code].
2021-05-07 13:41:39 +00:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "create_alternative_tile" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "alternative_id_override" type= "int" default= "-1" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Creates an alternative tile for the tile at coordinates [param atlas_coords]. If [param alternative_id_override] is -1, give it an automatically generated unique ID, or assigns it the given ID otherwise.
Returns the new alternative identifier, or -1 if the alternative could not be created with a provided [param alternative_id_override].
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "create_tile" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "size" type= "Vector2i" default= "Vector2i(1, 1)" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Creates a new tile at coordinates [param atlas_coords] with the given [param size].
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "get_atlas_grid_size" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2i" />
2021-05-07 13:41:39 +00:00
<description >
2021-09-06 09:56:31 +00:00
Returns the atlas grid size, which depends on how many tiles can fit in the texture. It thus depends on the Texture's size, the atlas [code]margins[/code] the tiles' [code]texture_region_size[/code].
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "get_next_alternative_tile_id" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-05-07 13:41:39 +00:00
<description >
2021-09-06 09:56:31 +00:00
Returns the alternative ID a following call to [method create_alternative_tile] would return.
2021-05-07 13:41:39 +00:00
</description>
</method>
2021-11-01 14:23:46 +00:00
<method name= "get_runtime_texture" qualifiers= "const" >
<return type= "Texture2D" />
<description >
If [member use_texture_padding] is [code]false[/code], returns [member texture]. Otherwise, returns and internal [ImageTexture] created that includes the padding.
</description>
</method>
<method name= "get_runtime_tile_texture_region" qualifiers= "const" >
<return type= "Rect2i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "frame" type= "int" />
2021-11-01 14:23:46 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns the region of the tile at coordinates [param atlas_coords] for the given [param frame] inside the texture returned by [method get_runtime_texture].
2021-11-01 14:23:46 +00:00
[b]Note:[/b] If [member use_texture_padding] is [code]false[/code], returns the same as [method get_tile_texture_region].
</description>
</method>
2021-09-10 14:23:36 +00:00
<method name= "get_tile_animation_columns" qualifiers= "const" >
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns how many columns the tile at [param atlas_coords] has in its animation layout.
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "get_tile_animation_frame_duration" qualifiers= "const" >
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "frame_index" type= "int" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns the animation frame duration of frame [param frame_index] for the tile at coordinates [param atlas_coords].
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "get_tile_animation_frames_count" qualifiers= "const" >
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns how many animation frames has the tile at coordinates [param atlas_coords].
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "get_tile_animation_separation" qualifiers= "const" >
<return type= "Vector2i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns the separation (as in the atlas grid) between each frame of an animated tile at coordinates [param atlas_coords].
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "get_tile_animation_speed" qualifiers= "const" >
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns the animation speed of the tile at coordinates [param atlas_coords].
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "get_tile_animation_total_duration" qualifiers= "const" >
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns the sum of the sum of the frame durations of the tile at coordinates [param atlas_coords]. This value needs to be divided by the animation speed to get the actual animation loop duration.
2021-09-10 14:23:36 +00:00
</description>
</method>
2021-05-07 13:41:39 +00:00
<method name= "get_tile_at_coords" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
If there is a tile covering the [param atlas_coords] coordinates, returns the top-left coordinates of the tile (thus its coordinate ID). Returns [code]Vector2i(-1, -1)[/code] otherwise.
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "get_tile_data" qualifiers= "const" >
2022-01-28 13:26:35 +00:00
<return type= "TileData" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "alternative_tile" type= "int" />
2021-05-07 13:41:39 +00:00
<description >
2021-09-06 09:56:31 +00:00
Returns the [TileData] object for the given atlas coordinates and alternative ID.
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "get_tile_size_in_atlas" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns the size of the tile (in the grid coordinates system) at coordinates [param atlas_coords].
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "get_tile_texture_region" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Rect2i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "frame" type= "int" default= "0" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns a tile's texture region in the atlas texture. For animated tiles, a [param frame] argument might be provided for the different frames of the animation.
2021-09-10 14:23:36 +00:00
</description>
</method>
2021-10-11 10:04:40 +00:00
<method name= "get_tiles_to_be_removed_on_change" >
<return type= "PackedVector2Array" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "texture" type= "Texture2D" />
<param index= "1" name= "margins" type= "Vector2i" />
<param index= "2" name= "separation" type= "Vector2i" />
<param index= "3" name= "texture_region_size" type= "Vector2i" />
2021-10-11 10:04:40 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns an array of tiles coordinates ID that will be automatically removed when modifying one or several of those properties: [param texture], [param margins], [param separation] or [param texture_region_size]. This can be used to undo changes that would have caused tiles data loss.
2021-10-11 10:04:40 +00:00
</description>
</method>
2021-09-10 14:23:36 +00:00
<method name= "has_room_for_tile" qualifiers= "const" >
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "size" type= "Vector2i" />
<param index= "2" name= "animation_columns" type= "int" />
<param index= "3" name= "animation_separation" type= "Vector2i" />
<param index= "4" name= "frames_count" type= "int" />
<param index= "5" name= "ignored_tile" type= "Vector2i" default= "Vector2i(-1, -1)" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Returns whether there is enough room in an atlas to create/modify a tile with the given properties. If [param ignored_tile] is provided, act as is the given tile was not present in the atlas. This may be used when you want to modify a tile's properties.
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "move_tile_in_atlas" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "new_atlas_coords" type= "Vector2i" default= "Vector2i(-1, -1)" />
<param index= "2" name= "new_size" type= "Vector2i" default= "Vector2i(-1, -1)" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Move the tile and its alternatives at the [param atlas_coords] coordinates to the [param new_atlas_coords] coordinates with the [param new_size] size. This functions will fail if a tile is already present in the given area.
If [param new_atlas_coords] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [param new_size] is [code]Vector2i(-1, -1)[/code], keeps the tile's size.
2021-09-10 14:23:36 +00:00
To avoid an error, first check if a move is possible using [method has_room_for_tile].
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "remove_alternative_tile" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "alternative_tile" type= "int" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Remove a tile's alternative with alternative ID [param alternative_tile].
Calling this function with [param alternative_tile] equals to 0 will fail, as the base tile alternative cannot be removed.
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "remove_tile" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Remove a tile and its alternative at coordinates [param atlas_coords].
2021-05-07 13:41:39 +00:00
</description>
</method>
<method name= "set_alternative_tile_id" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "alternative_tile" type= "int" />
<param index= "2" name= "new_id" type= "int" />
2021-05-07 13:41:39 +00:00
<description >
2022-08-09 15:19:47 +00:00
Change a tile's alternative ID from [param alternative_tile] to [param new_id].
Calling this function with [param new_id] of 0 will fail, as the base tile alternative cannot be moved.
2021-05-07 13:41:39 +00:00
</description>
</method>
2021-09-10 14:23:36 +00:00
<method name= "set_tile_animation_columns" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "frame_columns" type= "int" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Sets the number of columns in the animation layout of the tile at coordinates [param atlas_coords]. If set to 0, then the different frames of the animation are laid out as a single horizontal line in the atlas.
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "set_tile_animation_frame_duration" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "frame_index" type= "int" />
<param index= "2" name= "duration" type= "float" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Sets the animation frame [param duration] of frame [param frame_index] for the tile at coordinates [param atlas_coords].
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "set_tile_animation_frames_count" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "frames_count" type= "int" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Sets how many animation frames the tile at coordinates [param atlas_coords] has.
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "set_tile_animation_separation" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "separation" type= "Vector2i" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Sets the margin (in grid tiles) between each tile in the animation layout of the tile at coordinates [param atlas_coords] has.
2021-09-10 14:23:36 +00:00
</description>
</method>
<method name= "set_tile_animation_speed" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "atlas_coords" type= "Vector2i" />
<param index= "1" name= "speed" type= "float" />
2021-09-10 14:23:36 +00:00
<description >
2022-08-09 15:19:47 +00:00
Sets the animation speed of the tile at coordinates [param atlas_coords] has.
2021-09-10 14:23:36 +00:00
</description>
</method>
2021-05-07 13:41:39 +00:00
</methods>
<members >
2019-09-24 17:45:03 +00:00
<member name= "margins" type= "Vector2i" setter= "set_margins" getter= "get_margins" default= "Vector2i(0, 0)" >
2021-09-06 09:56:31 +00:00
Margins, in pixels, to offset the origin of the grid in the texture.
2021-05-07 13:41:39 +00:00
</member>
2019-09-24 17:45:03 +00:00
<member name= "separation" type= "Vector2i" setter= "set_separation" getter= "get_separation" default= "Vector2i(0, 0)" >
2021-09-06 09:56:31 +00:00
Separation, in pixels, between each tile texture region of the grid.
2021-05-07 13:41:39 +00:00
</member>
<member name= "texture" type= "Texture2D" setter= "set_texture" getter= "get_texture" >
2021-09-06 09:56:31 +00:00
The atlas texture.
2021-05-07 13:41:39 +00:00
</member>
2021-09-06 09:56:31 +00:00
<member name= "texture_region_size" type= "Vector2i" setter= "set_texture_region_size" getter= "get_texture_region_size" default= "Vector2i(16, 16)" >
The base tile size in the texture (in pixel). This size must be bigger than the TileSet's [code]tile_size[/code] value.
2021-05-07 13:41:39 +00:00
</member>
2021-11-01 14:23:46 +00:00
<member name= "use_texture_padding" type= "bool" setter= "set_use_texture_padding" getter= "get_use_texture_padding" default= "true" >
If [code]true[/code], generates an internal texture with an additional one pixel padding around each tile. Texture padding avoids a common artifact where lines appear between tiles.
Disabling this setting might lead a small performance improvement, as generating the internal texture requires both memory and processing time when the TileSetAtlasSource resource is modified.
</member>
2021-05-07 13:41:39 +00:00
</members>
</class>