PokéRogue
    Preparing search index...

    A Tileset is a combination of a single image containing the tiles and a container for data about each tile. It maps tile indexes (GIDs) to positions within the tileset image, stores per-tile properties and collision data, and supports tile spacing and margin. Tilesets are created automatically when parsing Tiled map data and are used by TilemapLayer during rendering.

    Index
    • Parameters

      • name: string

        The name of the tileset in the map data.

      • firstgid: number

        The first tile index this tileset contains.

      • OptionaltileWidth: number

        Width of each tile (in pixels). Default 32.

      • OptionaltileHeight: number

        Height of each tile (in pixels). Default 32.

      • OptionaltileMargin: number

        The margin around all tiles in the sheet (in pixels). Default 0.

      • OptionaltileSpacing: number

        The spacing between each tile in the sheet (in pixels). Default 0.

      • OptionaltileProperties: object

        Custom properties defined per tile in the Tileset. These typically are custom properties created in Tiled when editing a tileset. Default {}.

      • OptionaltileData: object

        Data stored per tile. These typically are created in Tiled when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. Default {}.

      • OptionaltileOffset: object

        Tile texture drawing offset. Default {x: 0, y: 0}.

      Returns Tileset

    animationSearchThreshold: number

    The number of frames above which a tile is considered to have many animation frames. This is used to optimize rendering. If a tile has fewer frames than this, frames are searched using a linear search. If a tile has more, frames are searched using a binary search.

    columns: number

    The number of tile columns in the tileset.

    firstgid: number

    The starting index of the first tile index this Tileset contains.

    glTexture: WebGLTextureWrapper | null

    The gl texture used by the WebGL renderer.

    image: Texture | null

    The cached image that contains the individual tiles. Use setImage to set.

    maxAnimationLength: number

    The maximum length of any animation in this tileset, in frames. This is used internally to optimize rendering. It is updated when createAnimationDataTexture is called.

    name: string

    The name of the Tileset.

    rows: number

    The number of tile rows in the tileset.

    texCoordinates: object[]

    The look-up table to specific tile image texture coordinates (UV in pixels). Each element contains the coordinates for a tile in an object of the form {x, y}.

    tileData: object

    Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within the Tileset collision editor. This is where collision objects and terrain are stored.

    tileHeight: number

    The height of each tile (in pixels). Use setTileSize to change.

    tileMargin: number

    The margin around the tiles in the sheet (in pixels). Use setSpacing to change.

    tileOffset: Vector2

    Controls the drawing offset from the tile origin. Defaults to 0x0, no offset.

    tileProperties: object

    Tileset-specific properties per tile that are typically defined in the Tiled editor in the Tileset editor.

    tileSpacing: number

    The spacing between each tile in the sheet (in pixels). Use setSpacing to change.

    tileWidth: number

    The width of each tile (in pixels). Use setTileSize to change.

    total: number

    The total number of tiles in the tileset.

    • Returns true if and only if this Tileset contains the given tile index.

      Parameters

      • tileIndex: number

        The unique id of the tile across all tilesets in the map.

      Returns boolean

      undefined

    • Creates a new WebGLTexture for the tileset's animation data.

      Parameters

      Returns WebGLTextureWrapper

      The new WebGLTexture.

    • Returns the ID of the tile to use, given a base tile and time, according to the tile's animation properties.

      If the tile is not animated, this method returns the base tile ID.

      Parameters

      • tileIndex: number

        The unique id of the tile across all tilesets in the map.

      • milliseconds: number

        The current time in milliseconds.

      Returns number | null

      The tile ID to use, or null if the tile is not contained in this tileset.

    • Get or create the map from tile index to animation data index. This is used by TilemapGPULayer to animate tiles.

      Parameters

      Returns Map<number, number>

      The map from tile index to animation data index.

    • Get or create the texture containing the animation data for this tileset. This is used by TilemapGPULayer to animate tiles.

      Parameters

      Returns WebGLTextureWrapper

      The animation data texture.

    • Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not contained in this Tileset. This is typically defined within Tiled's tileset collision editor.

      Parameters

      • tileIndex: number

        The unique id of the tile across all tilesets in the map.

      Returns object | null

      undefined

    • Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained in this Tileset. This is typically defined in Tiled and will contain both Tileset collision info and terrain mapping.

      Parameters

      • tileIndex: number

        The unique id of the tile across all tilesets in the map.

      Returns object | undefined

      undefined

    • Get a tile's properties that are stored in the Tileset. Returns null if tile index is not contained in this Tileset. This is typically defined in Tiled under the Tileset editor.

      Parameters

      • tileIndex: number

        The unique id of the tile across all tilesets in the map.

      Returns object | null | undefined

      undefined

    • Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. Returns null if tile index is not contained in this Tileset.

      Parameters

      • tileIndex: number

        The unique id of the tile across all tilesets in the map.

      Returns object | null

      Object in the form { x, y } representing the top-left UV coordinate within the Tileset image.

    • Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.).

      Parameters

      • texture: Texture

        The image that contains the tiles.

      Returns Tileset

      This Tileset object.

    • Sets the tile margin and spacing and updates the tile data (rows, columns, etc.).

      Parameters

      • Optionalmargin: number

        The margin around the tiles in the sheet (in pixels).

      • Optionalspacing: number

        The spacing between the tiles in the sheet (in pixels).

      Returns Tileset

      This Tileset object.

    • Sets the tile width & height and updates the tile data (rows, columns, etc.).

      Parameters

      • OptionaltileWidth: number

        The width of a tile in pixels.

      • OptionaltileHeight: number

        The height of a tile in pixels.

      Returns Tileset

      This Tileset object.

    • Updates tile texture coordinates and tileset data.

      Parameters

      • imageWidth: number

        The (expected) width of the image to slice.

      • imageHeight: number

        The (expected) height of the image to slice.

      • OptionaloffsetX: number

        The x offset in the source texture where the tileset starts. Default 0.

      • OptionaloffsetY: number

        The y offset in the source texture where the tileset starts. Default 0.

      Returns Tileset

      This Tileset object.