TileSet

Inherits: Resource < Reference < Object

Tile library for tilemaps.

Description

A TileSet is a library of tiles for a TileMap. It contains a list of tiles, each consisting of a sprite and optional collision shapes.

Tiles are referenced by a unique integer ID.

Tutorials

Methods

Vector2

_forward_atlas_subtile_selection ( int atlastile_id, Object tilemap, Vector2 tile_location ) virtual

Vector2

_forward_subtile_selection ( int autotile_id, int bitmask, Object tilemap, Vector2 tile_location ) virtual

bool

_is_tile_bound ( int drawn_id, int neighbor_id ) virtual

void

autotile_clear_bitmask_map ( int id )

int

autotile_get_bitmask ( int id, Vector2 coord )

BitmaskMode

autotile_get_bitmask_mode ( int id ) const

FallbackMode

autotile_get_fallback_mode ( int id ) const

Vector2

autotile_get_icon_coordinate ( int id ) const

OccluderPolygon2D

autotile_get_light_occluder ( int id, Vector2 coord ) const

NavigationPolygon

autotile_get_navigation_polygon ( int id, Vector2 coord ) const

Vector2

autotile_get_size ( int id ) const

int

autotile_get_spacing ( int id ) const

int

autotile_get_subtile_priority ( int id, Vector2 coord )

int

autotile_get_z_index ( int id, Vector2 coord )

void

autotile_set_bitmask ( int id, Vector2 bitmask, int flag )

void

autotile_set_bitmask_mode ( int id, BitmaskMode mode )

void

autotile_set_fallback_mode ( int id, FallbackMode mode )

void

autotile_set_icon_coordinate ( int id, Vector2 coord )

void

autotile_set_light_occluder ( int id, OccluderPolygon2D light_occluder, Vector2 coord )

void

autotile_set_navigation_polygon ( int id, NavigationPolygon navigation_polygon, Vector2 coord )

void

autotile_set_size ( int id, Vector2 size )

void

autotile_set_spacing ( int id, int spacing )

void

autotile_set_subtile_priority ( int id, Vector2 coord, int priority )

void

autotile_set_z_index ( int id, Vector2 coord, int z_index )

void

clear ( )

void

create_tile ( int id )

int

find_tile_by_name ( String name ) const

int

get_last_unused_tile_id ( ) const

Array

get_tiles_ids ( ) const

void

remove_tile ( int id )

void

tile_add_shape ( int id, Shape2D shape, Transform2D shape_transform, bool one_way=false, Vector2 autotile_coord=Vector2( 0, 0 ) )

OccluderPolygon2D

tile_get_light_occluder ( int id ) const

ShaderMaterial

tile_get_material ( int id ) const

Color

tile_get_modulate ( int id ) const

String

tile_get_name ( int id ) const

NavigationPolygon

tile_get_navigation_polygon ( int id ) const

Vector2

tile_get_navigation_polygon_offset ( int id ) const

Texture

tile_get_normal_map ( int id ) const

Vector2

tile_get_occluder_offset ( int id ) const

Rect2

tile_get_region ( int id ) const

Shape2D

tile_get_shape ( int id, int shape_id ) const

int

tile_get_shape_count ( int id ) const

Vector2

tile_get_shape_offset ( int id, int shape_id ) const

bool

tile_get_shape_one_way ( int id, int shape_id ) const

float

tile_get_shape_one_way_margin ( int id, int shape_id ) const

Transform2D

tile_get_shape_transform ( int id, int shape_id ) const

Array

tile_get_shapes ( int id ) const

Texture

tile_get_texture ( int id ) const

Vector2

tile_get_texture_offset ( int id ) const

TileMode

tile_get_tile_mode ( int id ) const

int

tile_get_z_index ( int id ) const

void

tile_set_light_occluder ( int id, OccluderPolygon2D light_occluder )

void

tile_set_material ( int id, ShaderMaterial material )

void

tile_set_modulate ( int id, Color color )

void

tile_set_name ( int id, String name )

void

tile_set_navigation_polygon ( int id, NavigationPolygon navigation_polygon )

void

tile_set_navigation_polygon_offset ( int id, Vector2 navigation_polygon_offset )

void

tile_set_normal_map ( int id, Texture normal_map )

void

tile_set_occluder_offset ( int id, Vector2 occluder_offset )

void

tile_set_region ( int id, Rect2 region )

void

tile_set_shape ( int id, int shape_id, Shape2D shape )

void

tile_set_shape_offset ( int id, int shape_id, Vector2 shape_offset )

void

tile_set_shape_one_way ( int id, int shape_id, bool one_way )

void

tile_set_shape_one_way_margin ( int id, int shape_id, float one_way )

void

tile_set_shape_transform ( int id, int shape_id, Transform2D shape_transform )

void

tile_set_shapes ( int id, Array shapes )

void

tile_set_texture ( int id, Texture texture )

void

tile_set_texture_offset ( int id, Vector2 texture_offset )

void

tile_set_tile_mode ( int id, TileMode tilemode )

void

tile_set_z_index ( int id, int z_index )


Enumerations

enum BitmaskMode:

BitmaskMode BITMASK_2X2 = 0

BitmaskMode BITMASK_3X3_MINIMAL = 1

BitmaskMode BITMASK_3X3 = 2


enum FallbackMode:

FallbackMode FALLBACK_AUTO = 0

Autotiles will automatically find a best match for missing tiles if they're incomplete.

FallbackMode FALLBACK_ICON = 1

Autotiles will use the icon tile for missing tiles if they're incomplete.


enum AutotileBindings:

AutotileBindings BIND_TOPLEFT = 1

AutotileBindings BIND_TOP = 2

AutotileBindings BIND_TOPRIGHT = 4

AutotileBindings BIND_LEFT = 8

AutotileBindings BIND_CENTER = 16

AutotileBindings BIND_RIGHT = 32

AutotileBindings BIND_BOTTOMLEFT = 64

AutotileBindings BIND_BOTTOM = 128

AutotileBindings BIND_BOTTOMRIGHT = 256


enum TileMode:

TileMode SINGLE_TILE = 0

TileMode AUTO_TILE = 1

TileMode ATLAS_TILE = 2


Method Descriptions

Vector2 _forward_atlas_subtile_selection ( int atlastile_id, Object tilemap, Vector2 tile_location ) virtual

There is currently no description for this method. Please help us by contributing one!


Vector2 _forward_subtile_selection ( int autotile_id, int bitmask, Object tilemap, Vector2 tile_location ) virtual

There is currently no description for this method. Please help us by contributing one!


bool _is_tile_bound ( int drawn_id, int neighbor_id ) virtual

Determines when the auto-tiler should consider two different auto-tile IDs to be bound together.

Note: neighbor_id will be -1 (TileMap.INVALID_CELL) when checking a tile against an empty neighbor tile.


void autotile_clear_bitmask_map ( int id )

Clears all bitmask information of the autotile.


int autotile_get_bitmask ( int id, Vector2 coord )

Returns the bitmask of the subtile from an autotile given its coordinates.

The value is the sum of the values in AutotileBindings present in the subtile (e.g. a value of 5 means the bitmask has bindings in both the top left and top right).


BitmaskMode autotile_get_bitmask_mode ( int id ) const

Returns the BitmaskMode of the autotile.


FallbackMode autotile_get_fallback_mode ( int id ) const

Returns the FallbackMode of the autotile.


Vector2 autotile_get_icon_coordinate ( int id ) const

Returns the subtile that's being used as an icon in an atlas/autotile given its coordinates.

The subtile defined as the icon will be used as a fallback when the atlas/autotile's bitmask information is incomplete. It will also be used to represent it in the TileSet editor.


OccluderPolygon2D autotile_get_light_occluder ( int id, Vector2 coord ) const

Returns the light occluder of the subtile from an atlas/autotile given its coordinates.


NavigationPolygon autotile_get_navigation_polygon ( int id, Vector2 coord ) const

Returns the navigation polygon of the subtile from an atlas/autotile given its coordinates.


Vector2 autotile_get_size ( int id ) const

Returns the size of the subtiles in an atlas/autotile.


int autotile_get_spacing ( int id ) const

Returns the spacing between subtiles of the atlas/autotile.


int autotile_get_subtile_priority ( int id, Vector2 coord )

Returns the priority of the subtile from an autotile given its coordinates.

When more than one subtile has the same bitmask value, one of them will be picked randomly for drawing. Its priority will define how often it will be picked.


int autotile_get_z_index ( int id, Vector2 coord )

Returns the drawing index of the subtile from an atlas/autotile given its coordinates.


void autotile_set_bitmask ( int id, Vector2 bitmask, int flag )

Sets the bitmask of the subtile from an autotile given its coordinates.

The value is the sum of the values in AutotileBindings present in the subtile (e.g. a value of 5 means the bitmask has bindings in both the top left and top right).


void autotile_set_bitmask_mode ( int id, BitmaskMode mode )

Sets the BitmaskMode of the autotile.


void autotile_set_fallback_mode ( int id, FallbackMode mode )

Returns the FallbackMode of the autotile.


void autotile_set_icon_coordinate ( int id, Vector2 coord )

Sets the subtile that will be used as an icon in an atlas/autotile given its coordinates.

The subtile defined as the icon may be used as a fallback when the atlas/autotile's bitmask information is incomplete. It will also be used to represent it in the TileSet editor.


void autotile_set_light_occluder ( int id, OccluderPolygon2D light_occluder, Vector2 coord )

Sets the light occluder of the subtile from an atlas/autotile given its coordinates.


void autotile_set_navigation_polygon ( int id, NavigationPolygon navigation_polygon, Vector2 coord )

Sets the navigation polygon of the subtile from an atlas/autotile given its coordinates.


void autotile_set_size ( int id, Vector2 size )

Sets the size of the subtiles in an atlas/autotile.


void autotile_set_spacing ( int id, int spacing )

Sets the spacing between subtiles of the atlas/autotile.


void autotile_set_subtile_priority ( int id, Vector2 coord, int priority )

Sets the priority of the subtile from an autotile given its coordinates.

When more than one subtile has the same bitmask value, one of them will be picked randomly for drawing. Its priority will define how often it will be picked.


void autotile_set_z_index ( int id, Vector2 coord, int z_index )

Sets the drawing index of the subtile from an atlas/autotile given its coordinates.


void clear ( )

Clears all tiles.


void create_tile ( int id )

Creates a new tile with the given ID.


int find_tile_by_name ( String name ) const

Returns the first tile matching the given name.


int get_last_unused_tile_id ( ) const

Returns the ID following the last currently used ID, useful when creating a new tile.


Array get_tiles_ids ( ) const

Returns an array of all currently used tile IDs.


void remove_tile ( int id )

Removes the given tile ID.


void tile_add_shape ( int id, Shape2D shape, Transform2D shape_transform, bool one_way=false, Vector2 autotile_coord=Vector2( 0, 0 ) )

Adds a shape to the tile.


OccluderPolygon2D tile_get_light_occluder ( int id ) const

Returns the tile's light occluder.


ShaderMaterial tile_get_material ( int id ) const

Returns the tile's material.


Color tile_get_modulate ( int id ) const

Returns the tile's modulation color.


String tile_get_name ( int id ) const

Returns the tile's name.


NavigationPolygon tile_get_navigation_polygon ( int id ) const

Returns the navigation polygon of the tile.


Vector2 tile_get_navigation_polygon_offset ( int id ) const

Returns the offset of the tile's navigation polygon.


Texture tile_get_normal_map ( int id ) const

Returns the tile's normal map texture.


Vector2 tile_get_occluder_offset ( int id ) const

Returns the offset of the tile's light occluder.


Rect2 tile_get_region ( int id ) const

Returns the tile sub-region in the texture.


Shape2D tile_get_shape ( int id, int shape_id ) const

Returns a tile's given shape.


int tile_get_shape_count ( int id ) const

Returns the number of shapes assigned to a tile.


Vector2 tile_get_shape_offset ( int id, int shape_id ) const

Returns the offset of a tile's shape.


bool tile_get_shape_one_way ( int id, int shape_id ) const

Returns the one-way collision value of a tile's shape.


float tile_get_shape_one_way_margin ( int id, int shape_id ) const

There is currently no description for this method. Please help us by contributing one!


Transform2D tile_get_shape_transform ( int id, int shape_id ) const

Returns the Transform2D of a tile's shape.


Array tile_get_shapes ( int id ) const

Returns an array of dictionaries describing the tile's shapes.

Dictionary structure in the array returned by this method:

{
    "autotile_coord": Vector2,
    "one_way": bool,
    "one_way_margin": int,
    "shape": CollisionShape2D,
    "shape_transform": Transform2D,
}

Texture tile_get_texture ( int id ) const

Returns the tile's texture.


Vector2 tile_get_texture_offset ( int id ) const

Returns the texture offset of the tile.


TileMode tile_get_tile_mode ( int id ) const

Returns the tile's TileMode.


int tile_get_z_index ( int id ) const

Returns the tile's Z index (drawing layer).


void tile_set_light_occluder ( int id, OccluderPolygon2D light_occluder )

Sets a light occluder for the tile.


void tile_set_material ( int id, ShaderMaterial material )

Sets the tile's material.


void tile_set_modulate ( int id, Color color )

Sets the tile's modulation color.

Note: Modulation is performed by setting the tile's vertex color. To access this in a shader, use COLOR rather than MODULATE (which instead accesses the TileMap's CanvasItem.modulate property).


void tile_set_name ( int id, String name )

Sets the tile's name.


void tile_set_navigation_polygon ( int id, NavigationPolygon navigation_polygon )

Sets the tile's navigation polygon.


void tile_set_navigation_polygon_offset ( int id, Vector2 navigation_polygon_offset )

Sets an offset for the tile's navigation polygon.


void tile_set_normal_map ( int id, Texture normal_map )

Sets the tile's normal map texture.

Note: Godot expects the normal map to use X+, Y-, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.


void tile_set_occluder_offset ( int id, Vector2 occluder_offset )

Sets an offset for the tile's light occluder.


void tile_set_region ( int id, Rect2 region )

Sets the tile's sub-region in the texture. This is common in texture atlases.


void tile_set_shape ( int id, int shape_id, Shape2D shape )

Sets a shape for the tile, enabling collision.


void tile_set_shape_offset ( int id, int shape_id, Vector2 shape_offset )

Sets the offset of a tile's shape.


void tile_set_shape_one_way ( int id, int shape_id, bool one_way )

Enables one-way collision on a tile's shape.


void tile_set_shape_one_way_margin ( int id, int shape_id, float one_way )

There is currently no description for this method. Please help us by contributing one!


void tile_set_shape_transform ( int id, int shape_id, Transform2D shape_transform )

Sets a Transform2D on a tile's shape.


void tile_set_shapes ( int id, Array shapes )

Sets an array of shapes for the tile, enabling collision.


void tile_set_texture ( int id, Texture texture )

Sets the tile's texture.


void tile_set_texture_offset ( int id, Vector2 texture_offset )

Sets the tile's texture offset.


void tile_set_tile_mode ( int id, TileMode tilemode )

Sets the tile's TileMode.


void tile_set_z_index ( int id, int z_index )

Sets the tile's drawing index.