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 baseTexture
PIXI.BaseTexture Required Pixi var.
-
canvas
-
- Source:
Properties:
Name Type Description canvas
HTMLCanvasElement The canvas to which this BitmapData draws.
-
context
-
- Source:
Properties:
Name Type Description context
CanvasRenderingContext2D The 2d context of the canvas.
-
dirty
-
- Source:
Properties:
Name Type Description dirty
boolean 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 fixedToCamera
boolean Fixes this layer to the Camera.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game A reference to the currently running Game.
-
<readonly> heightInPixels
-
- Source:
Properties:
Name Type Description heightInPixels
number Do NOT recommend changing after the map is loaded!
-
index
-
- Source:
Properties:
Name Type Description index
number -
layer
-
- Source:
Properties:
Name Type Description layer
number Tilemap layer index.
-
renderHeight
-
- Source:
Properties:
Name Type Description renderHeight
number The height of the area being rendered.
-
renderWidth
-
- Source:
Properties:
Name Type Description renderWidth
number The width of the area being rendered.
-
scrollFactorX
-
- Default Value:
- 1
- Source:
Properties:
Name Type Description scrollFactorX
number 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 scrollFactorY
number 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 scrollX
number Scrolls the map horizontally or returns the current x position.
-
scrollY
-
- Source:
Properties:
Name Type Description scrollY
number Scrolls the map vertically or returns the current y position.
-
texture
-
- Source:
Properties:
Name Type Description texture
PIXI.Texture Required Pixi var.
-
textureFrame
-
- Source:
Properties:
Name Type Description textureFrame
Phaser.Frame Dimensions of the renderable area.
-
tileHeight
-
- Source:
Properties:
Name Type Description tileHeight
number The height of a single tile in pixels.
-
tilemap
-
- Source:
Properties:
Name Type Description tilemap
Phaser.Tilemap The Tilemap to which this layer is bound.
-
tileMargin
-
- Source:
Properties:
Name Type Description tileMargin
number The margin around the tiles.
-
tileset
-
- Source:
Properties:
Name Type Description tileset
Phaser.Tileset The tile set used for rendering.
-
tileSpacing
-
- Source:
Properties:
Name Type Description tileSpacing
number The spacing around the tiles.
-
tileWidth
-
- Source:
Properties:
Name Type Description tileWidth
number The width of a single tile in pixels.
-
type
-
- Source:
Properties:
Name Type Description type
number The const type of this object.
-
<readonly> widthInPixels
-
- Source:
Properties:
Name Type Description widthInPixels
number 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 x
number X position of the top left of the area to copy (given in tiles, not pixels)
y
number Y position of the top left of the area to copy (given in tiles, not pixels)
width
number The width of the area to copy (given in tiles, not pixels)
height
number The height of the area to copy (given in tiles, not pixels)
collides
boolean 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 x
number 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 x
number X position of the point in target tile.
y
number 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 y
number 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 tilemap
Phaser.Tilemap The tilemap to which this layer belongs.
layer
number 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 tileset
Phaser.Tileset | string The tileset to use for this layer.
- Source: