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 baseTexture
PIXI.BaseTexture Required Pixi var.
-
cameraOffset
-
- Source:
Properties:
Name Type Description cameraOffset
Phaser.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 canvas
HTMLCanvasElement The canvas to which this TilemapLayer draws.
-
collisionHeight
-
- Source:
Properties:
Name Type Description collisionHeight
number The height of the collision tiles.
-
collisionWidth
-
- Source:
Properties:
Name Type Description collisionWidth
number The width of the collision tiles.
-
context
-
- Source:
Properties:
Name Type Description context
CanvasRenderingContext2D The 2d context of the canvas.
-
debug
-
- Default Value:
- false
- Source:
Properties:
Name Type Description debug
boolean 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 debugAlpha
number 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 debugCallbackColor
string 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 debugColor
string 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 debugFill
boolean 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 debugFillColor
string 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 dirty
boolean 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 fixedToCamera
boolean Fixes this object to the Camera.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game A reference to the currently running Game.
-
index
-
- Source:
Properties:
Name Type Description index
number The index of this layer within the Tilemap.
-
layer
-
- Source:
Properties:
Name Type Description layer
object The layer object within the Tilemap that this layer represents.
-
map
-
- Source:
Properties:
Name Type Description map
Phaser.Tilemap The Tilemap to which this layer is bound.
-
name
-
- Source:
Properties:
Name Type Description name
string The name of the layer.
-
rayStepRate
-
- Default Value:
- 4
- Source:
Properties:
Name Type Description rayStepRate
number 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 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.
-
tileColor
-
- Default Value:
- "rgb(255, 255, 255)"
- Source:
Properties:
Name Type Description tileColor
string 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 type
number The const type of this object.
Methods
-
getRayCastTiles(line, stepRate, collides, interestingFace) → {array.<Phaser.Tile>}
-
Gets all tiles that intersect with the given line.
Parameters:
Name Type Argument Default Description line
Phaser.Line The line used to determine which tiles to return.
stepRate
number <optional>
How many steps through the ray will we check? If undefined or null it uses TilemapLayer.rayStepRate.
collides
boolean <optional>
false If true only return tiles that collide on one or more faces.
interestingFace
boolean <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 x
number X position of the top left corner.
y
number Y position of the top left corner.
width
number Width of the area to get.
height
number Height of the area to get.
collides
boolean <optional>
false If true only return tiles that collide on one or more faces.
interestingFace
boolean <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 x
number 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 x
number X position of the point in target tile.
y
number Y position of the point in target tile.
point
Phaser.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 y
number 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: