Class: TilemapLayer

Phaser. TilemapLayer

Phaser.TilemapLayer

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

Properties:
Name Type Description
baseTexture PIXI.BaseTexture

Required Pixi var.

Source:

cameraOffset

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.

Source:

canvas

Properties:
Name Type Description
canvas HTMLCanvasElement

The canvas to which this TilemapLayer draws.

Source:

collisionHeight

Properties:
Name Type Description
collisionHeight number

The height of the collision tiles.

Source:

collisionWidth

Properties:
Name Type Description
collisionWidth number

The width of the collision tiles.

Source:

context

Properties:
Name Type Description
context CanvasRenderingContext2D

The 2d context of the canvas.

Source:

debug

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.

Default Value:
  • false
Source:

debugAlpha

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.

Default Value:
  • 0.5
Source:

debugCallbackColor

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.

Default Value:
  • "rgba(255, 0, 0, 1)"
Source:

debugColor

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.

Default Value:
  • "rgba(0, 255, 0, 1)"
Source:

debugFill

Properties:
Name Type Description
debugFill boolean

If true the debug tiles are filled with debugFillColor AND stroked around.

Default Value:
  • false
Source:

debugFillColor

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.

Default Value:
  • "rgba(0, 255, 0, 0.2)"
Source:

dirty

Properties:
Name Type Description
dirty boolean

Flag controlling when to re-render the layer.

Source:

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.

Properties:
Name Type Description
fixedToCamera boolean

Fixes this object to the Camera.

Default Value:
  • true
Source:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running Game.

Source:

index

Properties:
Name Type Description
index number

The index of this layer within the Tilemap.

Source:

layer

Properties:
Name Type Description
layer object

The layer object within the Tilemap that this layer represents.

Source:

map

Properties:
Name Type Description
map Phaser.Tilemap

The Tilemap to which this layer is bound.

Source:

name

Properties:
Name Type Description
name string

The name of the layer.

Source:

rayStepRate

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.

Default Value:
  • 4
Source:

scrollFactorX

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)

Default Value:
  • 1
Source:

scrollFactorY

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)

Default Value:
  • 1
Source:

scrollX

Properties:
Name Type Description
scrollX number

Scrolls the map horizontally or returns the current x position.

Source:

scrollY

Properties:
Name Type Description
scrollY number

Scrolls the map vertically or returns the current y position.

Source:

texture

Properties:
Name Type Description
texture PIXI.Texture

Required Pixi var.

Source:

textureFrame

Properties:
Name Type Description
textureFrame Phaser.Frame

Dimensions of the renderable area.

Source:

tileColor

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.

Default Value:
  • "rgb(255, 255, 255)"
Source:

type

Properties:
Name Type Description
type number

The const type of this object.

Source:

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:
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Fri Mar 28 2014 01:41:40 GMT-0000 (GMT) using the DocStrap template.