new TilemapLayer(game, tilemap, index, width, height)
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. |
tilemap |
Phaser.Tilemap | The tilemap to which this layer belongs. |
index |
number | The layer index within the map that this TilemapLayer represents. |
width |
number | Width of the renderable area of the layer. |
height |
number | Height of the renderable area of the layer. |
- Source:
Members
-
baseTexture
-
- Source:
Properties:
Name Type Description baseTexturePIXI.BaseTexture Required Pixi var.
-
cameraOffset
-
- Source:
Properties:
Name Type Description cameraOffsetPhaser.Point If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
-
canvas
-
- Source:
Properties:
Name Type Description canvasHTMLCanvasElement The canvas to which this TilemapLayer draws.
-
collisionHeight
-
- Source:
Properties:
Name Type Description collisionHeightnumber The height of the collision tiles.
-
collisionWidth
-
- Source:
Properties:
Name Type Description collisionWidthnumber The width of the collision tiles.
-
context
-
- Source:
Properties:
Name Type Description contextCanvasRenderingContext2D The 2d context of the canvas.
-
debug
-
- Default Value:
- false
- Source:
Properties:
Name Type Description debugboolean If set to true the collideable tile edges path will be rendered. Only works when game is running in Phaser.CANVAS mode.
-
debugAlpha
-
- Default Value:
- 0.5
- Source:
Properties:
Name Type Description debugAlphanumber If debug is true then the tileset is rendered with this alpha level, to make the tile edges clearer.
-
debugCallbackColor
-
- Default Value:
- "rgba(255, 0, 0, 1)"
- Source:
Properties:
Name Type Description debugCallbackColorstring If debug is true this is the color used to outline the edges of tiles that have collision callbacks. Provide in hex or rgb/rgba string format.
-
debugColor
-
- Default Value:
- "rgba(0, 255, 0, 1)"
- Source:
Properties:
Name Type Description debugColorstring If debug is true this is the color used to outline the edges of collidable tiles. Provide in hex or rgb/rgba string format.
-
debugFill
-
- Default Value:
- false
- Source:
Properties:
Name Type Description debugFillboolean If true the debug tiles are filled with debugFillColor AND stroked around.
-
debugFillColor
-
- Default Value:
- "rgba(0, 255, 0, 0.2)"
- Source:
Properties:
Name Type Description debugFillColorstring If debugFill is true this is the color used to fill the tiles. Provide in hex or rgb/rgba string format.
-
dirty
-
- Source:
Properties:
Name Type Description dirtyboolean Flag controlling when to re-render the layer.
-
fixedToCamera
-
An object 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 object to the Camera.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running Game.
-
index
-
- Source:
Properties:
Name Type Description indexnumber The index of this layer within the Tilemap.
-
layer
-
- Source:
Properties:
Name Type Description layerobject The layer object within the Tilemap that this layer represents.
-
map
-
- Source:
Properties:
Name Type Description mapPhaser.Tilemap The Tilemap to which this layer is bound.
-
name
-
- Source:
Properties:
Name Type Description namestring The name of the layer.
-
rayStepRate
-
- Default Value:
- 4
- Source:
Properties:
Name Type Description rayStepRatenumber When ray-casting against tiles this is the number of steps it will jump. For larger tile sizes you can increase this to improve performance.
-
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.
-
tileColor
-
- Default Value:
- "rgb(255, 255, 255)"
- Source:
Properties:
Name Type Description tileColorstring If no tileset is given the tiles will be rendered as rectangles in this color. Provide in hex or rgb/rgba string format.
-
type
-
- Source:
Properties:
Name Type Description typenumber The const type of this object.
-
wrap
-
- Default Value:
- false
- Source:
Properties:
Name Type Description wrapboolean Flag controlling if the layer tiles wrap at the edges. Only works if the World size matches the Map size.
Methods
-
getRayCastTiles(line, stepRate, collides, interestingFace) → {array.<Phaser.Tile>}
-
Gets all tiles that intersect with the given line.
Parameters:
Name Type Argument Default Description linePhaser.Line The line used to determine which tiles to return.
stepRatenumber <optional>
How many steps through the ray will we check? If undefined or null it uses TilemapLayer.rayStepRate.
collidesboolean <optional>
false If true only return tiles that collide on one or more faces.
interestingFaceboolean <optional>
false If true only return tiles that have interesting faces.
- Source:
Returns:
An array of Phaser.Tiles.
- Type
- array.<Phaser.Tile>
-
getTiles(x, y, width, height, collides, interestingFace) → {array.<Phaser.Tile>}
-
Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles.
Parameters:
Name Type Argument Default Description xnumber X position of the top left corner.
ynumber Y position of the top left corner.
widthnumber Width of the area to get.
heightnumber Height of the area to get.
collidesboolean <optional>
false If true only return tiles that collide on one or more faces.
interestingFaceboolean <optional>
false If true only return tiles that have interesting faces.
- Source:
Returns:
An array of Phaser.Tiles.
- Type
- array.<Phaser.Tile>
-
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, point) → {Phaser.Point|object}
-
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.
pointPhaser.Point | object The Point object to set the x and y values on.
- Source:
Returns:
A Point object with its x and y properties set.
- Type
- Phaser.Point | object
-
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
-
postUpdate()
-
Automatically called by World.postUpdate. Handles cache updates.
- Source:
-
render()
-
Renders the tiles to the layer canvas and pushes to the display.
- Source:
-
renderDebug()
-
Renders a collision debug overlay on-top of the canvas. Called automatically by render when debug = true.
- Source:
-
resizeWorld()
-
Sets the world size to match the size of this layer.
- Source:
-
updateMax()
-
Internal function to update maximum values.
- Source: