Navigation
These archived docs are for Phaser 2.6.2 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. Tile

new Tile(layer, index, x, y, width, height)

A Tile is a representation of a single tile within the Tilemap.

Parameters
Name Type Description
layer object

The layer in the Tilemap data that this tile belongs to.

index number

The index of this tile type in the core map data.

x number

The x coordinate of this tile.

y number

The y coordinate of this tile.

width number

Width of the tile.

height number

Height of the tile.

Source code: tilemap/Tile.js (Line 19)

Public Properties

alpha : number

The alpha value at which this tile is drawn to the canvas.

Source code: tilemap/Tile.js (Line 84)

[readonly] bottom : number

The sum of the y and height properties.

Source code: tilemap/Tile.js (Line 396)

[readonly] canCollide : boolean

True if this tile can collide on any of its faces or has a collision callback set.

Source code: tilemap/Tile.js (Line 344)

centerX

Properties:
Name Type Description
width number

The width of the tile in pixels.

Source code: tilemap/Tile.js (Line 74)

centerY

Properties:
Name Type Description
height number

The height of the tile in pixels.

Source code: tilemap/Tile.js (Line 79)

collideDown : boolean

Indicating collide with any object on the bottom.

Source code: tilemap/Tile.js (Line 138)

collideLeft : boolean

Indicating collide with any object on the left.

Source code: tilemap/Tile.js (Line 120)

collideRight : boolean

Indicating collide with any object on the right.

Source code: tilemap/Tile.js (Line 126)

[readonly] collides : boolean

True if this tile can collide on any of its faces.

Source code: tilemap/Tile.js (Line 331)

collideUp : boolean

Indicating collide with any object on the top.

Source code: tilemap/Tile.js (Line 132)

collisionCallback : Function

Tile collision callback.

Source code: tilemap/Tile.js (Line 144)

collisionCallbackContext : Object

The context in which the collision callback will be called.

Source code: tilemap/Tile.js (Line 150)

faceBottom : boolean

Is the bottom of this tile an interesting edge?

Source code: tilemap/Tile.js (Line 104)

faceLeft : boolean

Is the left of this tile an interesting edge?

Source code: tilemap/Tile.js (Line 109)

faceRight : boolean

Is the right of this tile an interesting edge?

Source code: tilemap/Tile.js (Line 114)

faceTop : boolean

Is the top of this tile an interesting edge?

Source code: tilemap/Tile.js (Line 99)

flipped : boolean

Whether this tile is flipped (mirrored) or not.

Source code: tilemap/Tile.js (Line 49)

height : number

The height of the tile in pixels.

Source code: tilemap/Tile.js (Line 69)

index : number

The index of this tile within the map data corresponding to the tileset, or -1 if this represents a blank/null tile.

Source code: tilemap/Tile.js (Line 29)

layer : Object

The layer in the Tilemap data that this tile belongs to.

Source code: tilemap/Tile.js (Line 24)

[readonly] left : number

The x value in pixels.

Source code: tilemap/Tile.js (Line 357)

properties : Object

Tile specific properties.

Source code: tilemap/Tile.js (Line 89)

The sum of the x and width properties.

Source code: tilemap/Tile.js (Line 370)

rotation : number

The rotation angle of this tile.

Source code: tilemap/Tile.js (Line 44)

scanned : boolean

Has this tile been walked / turned into a poly?

Source code: tilemap/Tile.js (Line 94)

[readonly] top : number

The y value.

Source code: tilemap/Tile.js (Line 383)

width : number

The width of the tile in pixels.

Source code: tilemap/Tile.js (Line 64)

worldX

Properties:
Name Type Description
x number

The x map coordinate of this tile.

Source code: tilemap/Tile.js (Line 54)

worldY

Properties:
Name Type Description
y number

The y map coordinate of this tile.

Source code: tilemap/Tile.js (Line 59)

x : number

The x map coordinate of this tile.

Source code: tilemap/Tile.js (Line 34)

y : number

The y map coordinate of this tile.

Source code: tilemap/Tile.js (Line 39)

Public Methods

containsPoint(x, y) → {boolean}

Check if the given x and y world coordinates are within this Tile.

Parameters
Name Type Description
x number

The x coordinate to test.

y number

The y coordinate to test.

Returns
boolean -

True if the coordinates are within this Tile, otherwise false.

Source code: tilemap/Tile.js (Line 156)

copy(tile)

Copies the tile data and properties from the given tile to this tile.

Parameters
Name Type Description
tile Phaser.Tile

The tile to copy from.

Source code: tilemap/Tile.js (Line 305)

destroy()

Clean up memory.

Source code: tilemap/Tile.js (Line 220)

intersects(x, y, right, bottom)

Check for intersection with this tile.

Parameters
Name Type Description
x number

The x axis in pixels.

y number

The y axis in pixels.

right number

The right point.

bottom number

The bottom point.

Source code: tilemap/Tile.js (Line 170)

isInteresting(collides, faces) → {boolean}

Is this tile interesting?

Parameters
Name Type Description
collides boolean

If true will check any collides value.

faces boolean

If true will check any face value.

Returns
boolean -

True if the Tile is interesting, otherwise false.

Source code: tilemap/Tile.js (Line 275)

resetCollision()

Reset collision status flags.

Source code: tilemap/Tile.js (Line 256)

setCollision(left, right, up, down)

Sets the collision flags for each side of this tile and updates the interesting faces list.

Parameters
Name Type Description
left boolean

Indicating collide with any object on the left.

right boolean

Indicating collide with any object on the right.

up boolean

Indicating collide with any object on the top.

down boolean

Indicating collide with any object on the bottom.

Source code: tilemap/Tile.js (Line 233)

setCollisionCallback(callback, context)

Set a callback to be called when this tile is hit by an object.
The callback must true true for collision processing to take place.

Parameters
Name Type Description
callback function

Callback function.

context object

Callback will be called within this context.

Source code: tilemap/Tile.js (Line 205)