rapid-render
    Preparing search index...

    Class Tilemap

    Tilemap entity for rendering tiled maps.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    children: Entity[] = []
    data: (string | number)[][] = ...
    eachTile?: (
        tileId: string | number,
        mapX: number,
        mapY: number,
    ) => undefined | void | ISpriteRenderOptions
    error: Vec2 = ...
    game: Game
    globalZindex: number = 0
    localZindex: number = 0
    parent: null | Entity = null
    position: Vec2
    rapid: Rapid
    rotation: number
    scale: Vec2
    tags: string[]
    tileSet: TileSet
    transform: MatrixStack = ...
    ySortCallback: YSortCallback[] = []
    DEFAULT_ERROR: 0
    EMPTY_TILE: -1

    Accessors

    • get x(): number

      Returns number

    • set x(nx: number): void

      Parameters

      • nx: number

      Returns void

    • get y(): number

      Returns number

    • set y(ny: number): void

      Parameters

      • ny: number

      Returns void

    Methods

    • Collects renderable entities, excluding children unless they override onRender.

      Parameters

      • queue: Entity[]

        The array to collect renderable entities.

      Returns void

    • Fills a rectangular area with a specified tile ID.

      Parameters

      • tileId: string | number

        The tile ID to use for filling.

      • startX: number

        The starting X coordinate.

      • startY: number

        The starting Y coordinate.

      • width: number

        The width of the fill area.

      • height: number

        The height of the fill area.

      Returns void

    • Finds descendant entities matching a predicate.

      Parameters

      • predicate: (entity: Entity) => boolean

        Function to test each entity.

      • onlyFirst: boolean = true

        If true, returns only the first match; otherwise, returns all matches.

      Returns null | Entity | Entity[]

      A single entity, an array of entities, or null if no matches are found.

    • Finds descendant entities with all specified tags.

      Parameters

      • tags: string[]

        Array of tags to match.

      • onlyFirst: boolean = false

        If true, returns only the first match; otherwise, returns all matches.

      Returns null | Entity | Entity[]

      A single entity, an array of entities, or null if no matches are found.

    • Gets the tile ID at the specified map coordinates.

      Parameters

      • x: number

        The X coordinate (column) on the map.

      • y: number

        The Y coordinate (row) on the map.

      Returns undefined | string | number

      The tile ID (number or string) or undefined if coordinates are out of bounds.

    • Converts local coordinates to map coordinates.

      Parameters

      • local: Vec2

        The local coordinates to convert.

      Returns void

    • Converts map coordinates to local coordinates.

      Parameters

      • local: Vec2

        The map coordinates to convert.

      Returns void

    • Hook for custom update logic.

      Parameters

      • deltaTime: number

        Time elapsed since the last update in seconds.

      Returns void

    • Removes a tile at the specified map coordinates (sets it to EMPTY_TILE).

      Parameters

      • x: number

        The X coordinate (column) on the map.

      • y: number

        The Y coordinate (row) on the map.

      Returns boolean

      True if the tile was removed successfully, false if coordinates are out of bounds.

    • Replaces the entire tilemap data and updates dimensions.

      Parameters

      • newData: (string | number)[][]

        The new 2D array of tile data.

      Returns void

    • Sets a tile at the specified map coordinates.

      Parameters

      • x: number

        The X coordinate (column) on the map.

      • y: number

        The Y coordinate (row) on the map.

      • tileId: string | number

        The tile ID to set (number or string).

      Returns boolean

      True if the tile was set successfully, false if coordinates are out of bounds.

    • Updates the entity and its children.

      Parameters

      • deltaTime: number

        Time elapsed since the last update in seconds.

      Returns void

    • Updates the entity's transform, optionally updating parent transforms.

      Parameters

      • deep: boolean = false

        If true, recursively updates parent transforms.

      Returns void