Class: TilemapLayer

Phaser. TilemapLayer

Phaser.TilemapLayer

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

Properties:
Name Type Description
baseTexture PIXI.BaseTexture

Required Pixi var.

Source:

canvas

Properties:
Name Type Description
canvas HTMLCanvasElement

The canvas to which this BitmapData draws.

Source:

context

Properties:
Name Type Description
context CanvasRenderingContext2D

The 2d context of the canvas.

Source:

dirty

Properties:
Name Type Description
dirty boolean

Flag controlling when to re-render the layer.

Source:

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.

Properties:
Name Type Description
fixedToCamera boolean

Fixes this layer to the Camera.

Default Value:
  • true
Source:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running Game.

Source:

<readonly> heightInPixels

Properties:
Name Type Description
heightInPixels number

Do NOT recommend changing after the map is loaded!

Source:

index

Properties:
Name Type Description
index number
Source:

layer

Properties:
Name Type Description
layer number

Tilemap layer index.

Source:

renderHeight

Properties:
Name Type Description
renderHeight number

The height of the area being rendered.

Source:

renderWidth

Properties:
Name Type Description
renderWidth number

The width of the area being rendered.

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:

tileHeight

Properties:
Name Type Description
tileHeight number

The height of a single tile in pixels.

Source:

tilemap

Properties:
Name Type Description
tilemap Phaser.Tilemap

The Tilemap to which this layer is bound.

Source:

tileMargin

Properties:
Name Type Description
tileMargin number

The margin around the tiles.

Source:

tileset

Properties:
Name Type Description
tileset Phaser.Tileset

The tile set used for rendering.

Source:

tileSpacing

Properties:
Name Type Description
tileSpacing number

The spacing around the tiles.

Source:

tileWidth

Properties:
Name Type Description
tileWidth number

The width of a single tile in pixels.

Source:

type

Properties:
Name Type Description
type number

The const type of this object.

Source:

<readonly> widthInPixels

Properties:
Name Type Description
widthInPixels number

Do NOT recommend changing after the map is loaded!

Source:

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:
Phaser Copyright © 2012-2013 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Thu Nov 28 2013 15:56:34 GMT-0000 (GMT) using the DocStrap template.