phaser - v4.0.0-rc.4
    Preparing search index...

    A Tileset is a combination of a single image containing the tiles and a container for data about each tile.

    Index

    Constructors

    • 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

    Properties

    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.

    The gl texture used by the WebGL renderer.

    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 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: Math.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 the 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.

    Methods

    • 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

    • 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

    • 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>

    • 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

    • 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

    • Get a tiles 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

    • 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

    • 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

    • 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

    • 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