/** * a TMX Tile Layer Object * Tiled QT 0.7.x format * @category Tilemap */ export default class TMXLayer extends Renderable { /** * @param {object} map - layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer}) * @param {object} data - layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer}) * @param {number} tilewidth - width of each tile in pixels * @param {number} tileheight - height of each tile in pixels * @param {string} orientation - "isometric" or "orthogonal" * @param {TMXTilesetGroup} tilesets - tileset as defined in Tiled * @param {number} z - z-index position */ constructor(map: object, data: object, tilewidth: number, tileheight: number, orientation: string, tilesets: TMXTilesetGroup, z: number); tilewidth: any; tileheight: any; orientation: string; /** * Horizontal layer offset in tiles * @default 0 * @type {number} */ x: number; /** * Vertical layer offset in tiles * @default 0 * @type {number} */ y: number; /** * The Layer corresponding Tilesets * @type {TMXTilesetGroup} */ tilesets: TMXTilesetGroup; tileset: any; maxTileSize: { width: number; height: number; }; /** * All animated tilesets in this layer * @type {TMXTileset[]} */ animatedTilesets: TMXTileset[]; /** * Layer contains tileset animations * @type {boolean} */ isAnimated: boolean; /** * the order in which tiles on orthogonal tile layers are rendered. * (valid values are "left-down", "left-up", "right-down", "right-up") * @type {string} * @default "right-down" */ renderorder: string; /** * the layer class * @type {string} */ class: string; name: any; cols: number; rows: number; /** * The raw tile data for this layer. Each cell occupies two consecutive * `Uint16` slots: the GID (with flip bits stripped) and a 3-bit flip * mask. Cell `(x, y)` is at `layerData[(y * cols + x) * 2]` (row-major). * * The 16-bit GID slot caps per-tileset GIDs at 65 535. This matches the * planned WebGL2 shader path (`RG16UI` index texture) — switching to * `Uint32Array` would force a truncating copy at GPU upload time. * @type {Uint16Array} */ layerData: Uint16Array; /** * Lazy view cache of Tile objects, indexed by `y * cols + x` (row-major). * Allocated lazily on the first `cellAt` / `getTile` call — the renderer * hot path reads `layerData` directly and never touches this cache, so * for games that never call `getTile`/`cellAt` from user code, this * stays `null` for the layer's lifetime. Invalidated entry-by-entry by * `setTile` and `clearTile`. The raw bytes in `layerData` are the source * of truth; this exists only to preserve stable Tile identity across * repeated user-facing reads. * @type {Array|null} * @ignore */ cachedTile: Array | null; /** * Monotonically-increasing counter bumped by `setTile` and `clearTile`. * Renderers can compare against a stashed value to detect mutations and * decide whether to re-upload the layer data to the GPU. * @type {number} */ dataVersion: number; /** * How this layer is rendered. Resolved by `onActivateEvent` to one of: * - `"shader"` — WebGL2 procedural shader path (single quad per tileset, fragment GID lookup) * - `"prerender"`— offscreen-canvas bake at activation, blitted as one drawImage per frame * - `"perTile"` — per-frame loop, one drawImage per visible tile * * User code may set this to one of the above values (or the special * `"auto"`) before the layer is activated to override the engine's * default choice; Tiled custom properties named `renderMode` are * applied automatically via `applyTMXProperties`. If a forced mode * is ineligible (e.g. `"shader"` on Canvas), a one-shot warning is * emitted at activation and the layer falls back to the legacy path. * @type {string} * @default "auto" */ renderMode: string; onActivateEvent(): void; canvasRenderer: CanvasRenderer | undefined; preRender: boolean | undefined; /** * Resolve `this.renderMode` to one of "shader" / "prerender" / "perTile" * based on eligibility checks and user/world hints. Emits a single * `console.warn` at activation when a forced mode is ineligible, or * when an auto-eligible mode falls back due to a layer feature the GPU * path doesn't support (orientation, collection-of-image tileset, etc.). * @ignore */ _resolveRenderMode(): void; /** * Check whether this layer is eligible for the WebGL2 shader path. * @param {object} renderer * @param {boolean} gpuAllowed - whether `gpuTilemap` is enabled at the world level * @returns {{ok: boolean, reason?: string}} * @ignore */ _checkShaderEligibility(renderer: object, gpuAllowed: boolean): { ok: boolean; reason?: string; }; onDeactivateEvent(): void; /** * Set the TMX renderer for this layer object * @param {TMXRenderer} renderer * @example * // use the parent map default renderer * let layer = new me.TMXLayer(...); * layer.setRenderer(map.getRenderer()); */ setRenderer(renderer: TMXRenderer): void; renderer: any; /** * Return the layer current renderer object * @returns {TMXRenderer} renderer */ getRenderer(): TMXRenderer; /** * Return the TileId of the Tile at the specified position * @param {number} x - X coordinate (in world/pixels coordinates) * @param {number} y - Y coordinate (in world/pixels coordinates) * @returns {number} TileId or null if there is no Tile at the given position */ getTileId(x: number, y: number): number; /** * Return the Tile object at the specified position * @param {number} x - X coordinate (in world/pixels coordinates) * @param {number} y - Y coordinate (in world/pixels coordinates) * @returns {Tile} corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds * @example * // get the TMX Map Layer called "Front layer" * let layer = app.world.getChildByName("Front Layer")[0]; * // get the tile object corresponding to the latest pointer position * let tile = layer.getTile(me.input.pointer.x, me.input.pointer.y); */ getTile(x: number, y: number): Tile; /** * assign the given Tile object to the specified position * @param {Tile} tile - the tile object to be assigned * @param {number} x - x coordinate (in tile/column coordinates) * @param {number} y - y coordinate (in tile/row coordinates) * @returns {Tile} the tile object */ setTile(tile: Tile, x: number, y: number): Tile; _truncationWarned: boolean | undefined; /** * return a new the Tile object corresponding to the given tile id * @param {number} tileId - tileId * @param {number} x - X coordinate (in world/pixels coordinates) * @param {number} y - Y coordinate (in world/pixels coordinates) * @returns {Tile} the tile object */ getTileById(tileId: number, x: number, y: number): Tile; /** * Return the Tile object at the specified tile coordinates * @param {number} x - x position of the tile (in Tile unit) * @param {number} y - x position of the tile (in Tile unit) * @param {number} [boundsCheck=true] - check first if within the layer bounds * @returns {Tile} corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds * @example * // return the first tile at offset 0, 0 * let tile = layer.cellAt(0, 0); */ cellAt(x: number, y: number, boundsCheck?: number): Tile; /** * clear the tile at the specified position * @param {number} x - X coordinate (in map coordinates: row/column) * @param {number} y - Y coordinate (in map coordinates: row/column) * @example * app.world.getChildByType(me.TMXLayer).forEach(function(layer) { * // clear all tiles at the given x,y coordinates * layer.clearTile(x, y); * }); */ clearTile(x: number, y: number): void; /** * update animations in a tileset layer * @ignore */ update(dt: any): boolean; /** * draw a tileset layer * @ignore */ draw(renderer: any, rect: any): void; } import Renderable from "../../renderable/renderable.js"; import Tile from "./TMXTile.js"; import CanvasRenderer from "../../video/canvas/canvas_renderer"; //# sourceMappingURL=TMXLayer.d.ts.map