melonJS
    Preparing search index...

    Class IntGrid

    The values of an IntGrid layer of a level: a whole number per cell, 0 for an empty one, as painted in LDtk. What a game reads its walls, ladders, water and spawn areas from.

    Index
    cellSize: number

    the size of a cell, in pixels

    colors: Map<number, string>

    the color given to each value in LDtk, as #rrggbb

    cols: number

    the grid's width, in cells

    name: string

    the layer's identifier in LDtk

    names: Map<number, string>

    the name given to each value in LDtk, for the values that have one

    rows: number

    the grid's height, in cells

    values: Int32Array

    the values, row by row

    x: number

    where the grid's top left corner is, in the container the level was added to

    y: number

    where the grid's top left corner is, in the container the level was added to

    • the name of a cell's value, as given in LDtk

      Parameters

      • col: number

        the cell's column

      • row: number

        the cell's row

      Returns string | undefined

      the name, or undefined for an empty cell or a value with no name

    • Cover the cells holding the values asked for with few rectangles, each of one value: a wall of a thousand cells is one rectangle.

      Parameters

      • test: (value: number) => boolean = ...

        true for a value to cover; by default every value but 0

      Returns IntGridRect[]

      the rectangles, in pixels of the container the level was added to

    • the value of a cell

      Parameters

      • col: number

        the cell's column

      • row: number

        the cell's row

      Returns number

      its value; 0 for an empty cell and outside the grid

    • the value at a point of the container the level was added to

      Parameters

      • x: number

        the point

      • y: number

        the point

      Returns number

      the value of the cell there; 0 for an empty cell and outside the grid