new Tile(layer, index, x, y, width, height)
Create a new Tile object.
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:
Members
-
alpha
-
- Source:
Properties:
Name Type Description alphanumber The alpha value at which this tile is drawn to the canvas.
-
<readonly> bottom
-
- Source:
Properties:
Name Type Description bottomnumber The sum of the y and height properties.
-
<readonly> canCollide
-
- Source:
Properties:
Name Type Description canCollideboolean True if this tile can collide on any of its faces or has a collision callback set.
-
centerX
-
- Source:
Properties:
Name Type Description widthnumber The width of the tile in pixels.
-
centerY
-
- Source:
Properties:
Name Type Description heightnumber The height of the tile in pixels.
-
collideDown
-
- Default Value:
- false
- Source:
Properties:
Name Type Description collideDownboolean Indicating collide with any object on the bottom.
-
collideLeft
-
- Default Value:
- false
- Source:
Properties:
Name Type Description collideLeftboolean Indicating collide with any object on the left.
-
collideRight
-
- Default Value:
- false
- Source:
Properties:
Name Type Description collideRightboolean Indicating collide with any object on the right.
-
<readonly> collides
-
- Source:
Properties:
Name Type Description collidesboolean True if this tile can collide on any of its faces.
-
collideUp
-
- Default Value:
- false
- Source:
Properties:
Name Type Description collideUpboolean Indicating collide with any object on the top.
-
collisionCallback
-
- Default Value:
- null
- Source:
Properties:
Name Type Description collisionCallbackfunction Tile collision callback.
-
collisionCallbackContext
-
- Source:
Properties:
Name Type Description collisionCallbackContextobject The context in which the collision callback will be called.
-
faceBottom
-
- Source:
Properties:
Name Type Description faceBottomboolean Is the bottom of this tile an interesting edge?
-
faceLeft
-
- Source:
Properties:
Name Type Description faceLeftboolean Is the left of this tile an interesting edge?
-
faceRight
-
- Source:
Properties:
Name Type Description faceRightboolean Is the right of this tile an interesting edge?
-
faceTop
-
- Source:
Properties:
Name Type Description faceTopboolean Is the top of this tile an interesting edge?
-
height
-
- Source:
Properties:
Name Type Description heightnumber The height of the tile in pixels.
-
index
-
- Source:
Properties:
Name Type Description indexnumber The index of this tile within the map data corresponding to the tileset, or -1 if this represents a blank/null tile.
-
layer
-
- Source:
Properties:
Name Type Description layerobject The layer in the Tilemap data that this tile belongs to.
-
<readonly> left
-
- Source:
Properties:
Name Type Description leftnumber The x value in pixels.
-
properties
-
- Source:
Properties:
Name Type Description propertiesobject Tile specific properties.
-
<readonly> right
-
- Source:
Properties:
Name Type Description rightnumber The sum of the x and width properties.
-
scanned
-
- Source:
Properties:
Name Type Description scannedboolean Has this tile been walked / turned into a poly?
-
<readonly> top
-
- Source:
Properties:
Name Type Description topnumber The y value.
-
width
-
- Source:
Properties:
Name Type Description widthnumber The width of the tile in pixels.
-
worldX
-
- Source:
Properties:
Name Type Description xnumber The x map coordinate of this tile.
-
worldY
-
- Source:
Properties:
Name Type Description ynumber The y map coordinate of this tile.
-
x
-
- Source:
Properties:
Name Type Description xnumber The x map coordinate of this tile.
-
y
-
- Source:
Properties:
Name Type Description ynumber The y map coordinate of this tile.
Methods
-
containsPoint(x, y) → {boolean}
-
Check if the given x and y world coordinates are within this Tile.
Parameters:
Name Type Description xnumber The x coordinate to test.
ynumber The y coordinate to test.
- Source:
Returns:
True if the coordinates are within this Tile, otherwise false.
- Type
- boolean
-
copy(tile)
-
Copies the tile data and properties from the given tile to this tile.
Parameters:
Name Type Description tilePhaser.Tile The tile to copy from.
- Source:
-
destroy()
-
Clean up memory.
- Source:
-
intersects(x, y, right, bottom)
-
Check for intersection with this tile.
Parameters:
Name Type Description xnumber The x axis in pixels.
ynumber The y axis in pixels.
rightnumber The right point.
bottomnumber The bottom point.
- Source:
-
isInteresting(collides, faces) → {boolean}
-
Is this tile interesting?
Parameters:
Name Type Description collidesboolean If true will check any collides value.
facesboolean If true will check any face value.
- Source:
Returns:
True if the Tile is interesting, otherwise false.
- Type
- boolean
-
resetCollision()
-
Reset collision status flags.
- Source:
-
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 leftboolean Indicating collide with any object on the left.
rightboolean Indicating collide with any object on the right.
upboolean Indicating collide with any object on the top.
downboolean Indicating collide with any object on the bottom.
- Source:
-
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 callbackfunction Callback function.
contextobject Callback will be called within this context.
- Source: