new TilemapLayer(game, x, y, renderWidth, renderHeight, tileset, tilemap, layer)
A Tilemap Layer is a set of map data combined with a Tileset in order to render that data to the game.
Parameters:
| Name | Type | Description |
|---|---|---|
game |
Phaser.Game | Game reference to the currently running game. |
x |
number | The x coordinate of this layer. |
y |
number | The y coordinate of this layer. |
renderWidth |
number | Width of the layer. |
renderHeight |
number | Height of the layer. |
tileset |
Phaser.Tileset | string | The tile set used for rendering. |
tilemap |
Phaser.Tilemap | The tilemap to which this layer belongs. |
layer |
number | The layer index within the map. |
- Source:
Members
-
baseTexture
-
- Source:
Properties:
Name Type Description baseTexturePIXI.BaseTexture Required Pixi var.
-
canvas
-
- Source:
Properties:
Name Type Description canvasHTMLCanvasElement The canvas to which this BitmapData draws.
-
context
-
- Source:
Properties:
Name Type Description contextCanvasRenderingContext2D The 2d context of the canvas.
-
dirty
-
- Source:
Properties:
Name Type Description dirtyboolean Flag controlling when to re-render the layer.
-
fixedToCamera
-
A layer that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
- Default Value:
- true
- Source:
Properties:
Name Type Description fixedToCameraboolean Fixes this layer to the Camera.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running Game.
-
<readonly> heightInPixels
-
- Source:
Properties:
Name Type Description heightInPixelsnumber Do NOT recommend changing after the map is loaded!
-
index
-
- Source:
Properties:
Name Type Description indexnumber -
layer
-
- Source:
Properties:
Name Type Description layernumber Tilemap layer index.
-
renderHeight
-
- Source:
Properties:
Name Type Description renderHeightnumber The height of the area being rendered.
-
renderWidth
-
- Source:
Properties:
Name Type Description renderWidthnumber The width of the area being rendered.
-
scrollFactorX
-
- Default Value:
- 1
- Source:
Properties:
Name Type Description scrollFactorXnumber speed at which this layer scrolls horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do)
-
scrollFactorY
-
- Default Value:
- 1
- Source:
Properties:
Name Type Description scrollFactorYnumber speed at which this layer scrolls vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do)
-
scrollX
-
- Source:
Properties:
Name Type Description scrollXnumber Scrolls the map horizontally or returns the current x position.
-
scrollY
-
- Source:
Properties:
Name Type Description scrollYnumber Scrolls the map vertically or returns the current y position.
-
texture
-
- Source:
Properties:
Name Type Description texturePIXI.Texture Required Pixi var.
-
textureFrame
-
- Source:
Properties:
Name Type Description textureFramePhaser.Frame Dimensions of the renderable area.
-
tileHeight
-
- Source:
Properties:
Name Type Description tileHeightnumber The height of a single tile in pixels.
-
tilemap
-
- Source:
Properties:
Name Type Description tilemapPhaser.Tilemap The Tilemap to which this layer is bound.
-
tileMargin
-
- Source:
Properties:
Name Type Description tileMarginnumber The margin around the tiles.
-
tileset
-
- Source:
Properties:
Name Type Description tilesetPhaser.Tileset The tile set used for rendering.
-
tileSpacing
-
- Source:
Properties:
Name Type Description tileSpacingnumber The spacing around the tiles.
-
tileWidth
-
- Source:
Properties:
Name Type Description tileWidthnumber The width of a single tile in pixels.
-
type
-
- Source:
Properties:
Name Type Description typenumber The const type of this object.
-
<readonly> widthInPixels
-
- Source:
Properties:
Name Type Description widthInPixelsnumber Do NOT recommend changing after the map is loaded!
Methods
-
deltaAbsX() → {number}
-
Returns the absolute delta x value.
- Source:
Returns:
Absolute delta X value
- Type
- number
-
deltaAbsY() → {number}
-
Returns the absolute delta y value.
- Source:
Returns:
Absolute delta Y value
- Type
- number
-
deltaX() → {number}
-
Returns the delta x value.
- Source:
Returns:
Delta X value
- Type
- number
-
deltaY() → {number}
-
Returns the delta y value.
- Source:
Returns:
Delta Y value
- Type
- number
-
getTiles(x, y, width, height, collides) → {array}
-
Get the tiles within the given area.
Parameters:
Name Type Description xnumber X position of the top left of the area to copy (given in tiles, not pixels)
ynumber Y position of the top left of the area to copy (given in tiles, not pixels)
widthnumber The width of the area to copy (given in tiles, not pixels)
heightnumber The height of the area to copy (given in tiles, not pixels)
collidesboolean If true only return tiles that collide on one or more faces.
- Source:
Returns:
Array with tiles informations (each contains x, y, and the tile).
- Type
- array
-
getTileX(x) → {Phaser.Tile}
-
Convert a pixel value to a tile coordinate.
Parameters:
Name Type Description xnumber X position of the point in target tile.
- Source:
Returns:
The tile with specific properties.
- Type
- Phaser.Tile
-
getTileXY(x, y) → {Phaser.Tile}
-
Convert a pixel value to a tile coordinate.
Parameters:
Name Type Description xnumber X position of the point in target tile.
ynumber Y position of the point in target tile.
- Source:
Returns:
The tile with specific properties.
- Type
- Phaser.Tile
-
getTileY(y) → {Phaser.Tile}
-
Convert a pixel value to a tile coordinate.
Parameters:
Name Type Description ynumber Y position of the point in target tile.
- Source:
Returns:
The tile with specific properties.
- Type
- Phaser.Tile
-
render()
-
Renders the tiles to the layer canvas and pushes to the display.
- Source:
-
resizeWorld()
-
Sets the world size to match the size of this layer.
- Source:
-
update()
-
Automatically called by World.preUpdate. Handles cache updates.
- Source:
-
updateMapData(tilemap, layer)
-
Updates the Tilemap data.
Parameters:
Name Type Description tilemapPhaser.Tilemap The tilemap to which this layer belongs.
layernumber The layer index within the map.
- Source:
-
updateMax()
-
Internal function to update maximum values.
- Source:
-
updateTileset(tileset)
-
Updates the Tileset data.
Parameters:
Name Type Description tilesetPhaser.Tileset | string The tileset to use for this layer.
- Source: