melonJS
    Preparing search index...

    Class Tileset

    A set of tiles cut from one image on a regular grid, numbered row by row from firstgid: what a TileLayer draws its cells from. Built from a plain description, whatever the map editor. A tile can carry properties (Tileset#setTileProperty), a class (Tileset#setTileClass) and an animation (Tileset#setTileAnimation).

    // 16 x 16 tiles cut from a loaded image, used by a layer built in code
    const tilesets = new me.TilesetGroup();
    tilesets.add(new me.Tileset({ name: "ground", image: "ground", tilewidth: 16, tileheight: 16 }));
    const layer = new me.TileLayer({ name: "floor", cols: 40, rows: 30, tilewidth: 16, tileheight: 16, tilesets });
    layer.setCell(3, 2, 1);

    Hierarchy (View Summary)

    Index
    _animationTexture: TextureAtlas | undefined
    atlas: any
    class: string

    the tileset class (since Tiled 1.9, renamed back to type on tile/object in 1.10)

    fillmode: string

    fill mode when tiles are not rendered at native size (since Tiled 1.9)

    "stretch"
    
    firstgid: number

    the first global tile ID of this tileset

    image: any
    isAnimated: boolean

    Tileset contains animated tiles

    isCollection: boolean

    true if the tileset is a "Collection of Image" Tileset

    lastgid: number

    the last global tile ID of this tileset

    margin: number

    the margin around tiles in pixels

    0
    
    name: string

    the tileset name

    objectalignment: string

    the point of a tile object from this tileset that sits at its position: "topleft", "top", "topright", "left", "center", "right", "bottomleft", "bottom" or "bottomright". "unspecified" means the bottom left, or the bottom center on an isometric map

    "unspecified"
    
    spacing: number

    the spacing between tiles in pixels

    0
    
    texture: any
    tileheight: number

    the height of each tile in pixels

    tileoffset: Vector2d

    tile drawing offset

    tilerendersize: string

    how tiles render relative to the grid (since Tiled 1.9)

    "tile"
    
    tilewidth: number

    the width of each tile in pixels

    • return the class of the specified tile, as set on the tile in Tiled's tileset editor. A tile object with no class of its own is matched by it.

      Parameters

      • tileId: number

        global tile ID

      Returns string | undefined

      the tile's class, or undefined if it has none

    • return the tile image from a "Collection of Image" tileset

      Parameters

      • gid: number

      Returns HTMLCanvasElement | HTMLImageElement | undefined

      corresponding image or undefined

    • return the properties of the specified tile

      Parameters

      • tileId: number

        global tile ID

      Returns object | undefined

      tile properties or undefined

    • animate a tile: wherever it is drawn, it shows each frame's tile in turn, for the frame's duration, and starts over

      Parameters

      • tileId: number

        the tile's id within the tileset (its gid less firstgid)

      • frames: { duration: number; tileid: number }[]

        the tiles to show, by their id within the tileset, each with its duration in milliseconds

      Returns void

    • The id, within the tileset, of the tile whose top left corner is at a point of the tileset's image: for a map format that names a tile by where it is in the image, or numbers the tiles another way than row by row over the whole tiles the image holds.

      Parameters

      • x: number

        the tile's left edge in the image, in pixels

      • y: number

        the tile's top edge in the image, in pixels

      Returns number

      the tile's id (add firstgid for its global id), or -1 where no whole tile of the tileset starts