TileSet

    Category: Core

    Tile library for tilemaps.

    enum BitmaskMode:

    • BITMASK_2X2 = 0
    • BITMASK_3X3_MINIMAL = 1
    • BITMASK_3X3 = 2

    enum AutotileBindings:

    • BIND_TOPLEFT = 1
    • BIND_TOP = 2
    • BIND_TOPRIGHT = 4
    • BIND_LEFT = 8
    • BIND_RIGHT = 32
    • BIND_BOTTOMLEFT = 64
    • BIND_BOTTOM = 128
    • BIND_BOTTOMRIGHT = 256

    enum TileMode:

    • SINGLE_TILE = 0
    • AUTO_TILE = 1
    • ATLAS_TILE = 2

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

    Tiles are referenced by a unique integer ID.

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

    • _is_tile_bound ( int drawn_id, neighbor_id ) virtual

    • void autotile_clear_bitmask_map ( int id )

    Clears all bitmask info of the autotile.


    • autotile_get_bitmask ( int id, 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).


    • autotile_get_bitmask_mode ( int id ) const

    Returns the of the autotile.


    • Vector2 autotile_get_icon_coordinate ( 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 info is incomplete. It will also be used to represent it in the TileSet editor.


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


    • autotile_get_navigation_polygon ( int id, coord ) const

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


    • Vector2 autotile_get_size ( id ) const

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


    Returns the spacing between subtiles of the atlas/autotile.


    • int autotile_get_subtile_priority ( 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.


    • autotile_get_z_index ( int id, coord )

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


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

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

    The value is the sum of the values in 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, mode )

    Sets the BitmaskMode of the autotile.


    • void autotile_set_icon_coordinate ( id, Vector2 coord )

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


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


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

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


    • void autotile_set_size ( id, Vector2 size )

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


    • void autotile_set_spacing ( id, int spacing )

    Sets the spacing between subtiles of the atlas/autotile.


    • void autotile_set_subtile_priority ( id, Vector2 coord, 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, 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 ( id )

    Creates a new tile with the given ID.


    • int find_tile_by_name ( 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.


    • 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 ( id, Shape2D shape, shape_transform, bool one_way=false, autotile_coord=Vector2( 0, 0 ) )

    Adds a shape to the tile.


    Returns the tile’s light occluder.


    Returns the tile’s material.


    • Color tile_get_modulate ( id ) const

    Returns the tile’s modulation color.


    • String tile_get_name ( id ) const

    Returns the tile’s name.


    Returns the navigation polygon of the tile.


    • Vector2 tile_get_navigation_polygon_offset ( id ) const

    Returns the offset of the tile’s navigation polygon.


    • Texture tile_get_normal_map ( id ) const

    Returns the tile’s normal map texture.


    • Vector2 tile_get_occluder_offset ( id ) const

    Returns the offset of the tile’s light occluder.


    • Rect2 tile_get_region ( id ) const

    Returns the tile sub-region in the texture.


    • Shape2D tile_get_shape ( id, int shape_id ) const

    Returns a tile’s given shape.



    • tile_get_shape_offset ( int id, shape_id ) const

    Returns the offset of a tile’s shape.


    • bool tile_get_shape_one_way ( id, int shape_id ) const

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


    • tile_get_shape_one_way_margin ( int id, shape_id ) const

    Returns the of a tile’s shape.


    • Array tile_get_shapes ( id ) const

    Returns an array of the tile’s shapes.


    • Texture tile_get_texture ( id ) const

    Returns the tile’s texture.


    • Vector2 tile_get_texture_offset ( id ) const

    Returns the texture offset of the tile.


    • TileMode tile_get_tile_mode ( id ) const

    Returns the tile’s TileMode.


    • tile_get_z_index ( int id ) const

    Returns the tile’s z-index (drawing layer).


    Sets a light occluder for the tile.


    Sets the tile’s material.


    • void tile_set_modulate ( id, Color color )

    Sets the tile’s modulation color.


    • void tile_set_name ( id, String name )

    Sets the tile’s name.


    Sets the tile’s navigation polygon.


    • void tile_set_navigation_polygon_offset ( id, Vector2 navigation_polygon_offset )

    Sets an offset for the tile’s navigation polygon.


    • void tile_set_normal_map ( id, Texture normal_map )

    Sets the tile’s normal map texture.


    • void tile_set_occluder_offset ( id, Vector2 occluder_offset )

    Sets an offset for the tile’s light occluder.


    • void tile_set_region ( id, Rect2 region )

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


    • void tile_set_shape ( id, int shape_id, shape )

    Sets a shape for the tile, enabling collision.


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

    Sets the offset of a tile’s shape.


    • void tile_set_shape_one_way ( id, int shape_id, one_way )

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


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

    • void tile_set_shape_transform ( id, int shape_id, shape_transform )

    Sets a Transform2D on a tile’s shape.


    • void tile_set_shapes ( id, Array shapes )

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


    • void tile_set_texture ( id, Texture texture )

    Sets the tile’s texture.


    • void tile_set_texture_offset ( id, Vector2 texture_offset )

    Sets the tile’s texture offset.


    • void tile_set_tile_mode ( id, TileMode tilemode )

    • void tile_set_z_index ( id, int z_index )

    Sets the tile’s drawing index.