phaser - v4.0.0-rc.4
    Preparing search index...

    A Tile is a representation of a single tile within the Tilemap. This is a lightweight data representation, so its position information is stored without factoring in scroll, layer scale or layer position.

    Implements

    Index

    Constructors

    • Parameters

      • layer: LayerData

        The LayerData object in the Tilemap that this tile belongs to.

      • index: number

        The unique index of this tile within the map.

      • x: number

        The x coordinate of this tile in tile coordinates.

      • y: number

        The y coordinate of this tile in tile coordinates.

      • width: number

        Width of the tile in pixels.

      • height: number

        Height of the tile in pixels.

      • baseWidth: number

        The base width a tile in the map (in pixels). Tiled maps support multiple tileset sizes within one map, but they are still placed at intervals of the base tile width.

      • baseHeight: number

        The base height of the tile in pixels (in pixels). Tiled maps support multiple tileset sizes within one map, but they are still placed at intervals of the base tile height.

      Returns Tile

    Properties

    alpha: number

    The alpha value of the Game Object.

    This is a global value, impacting the entire Game Object, not just a region of it.

    baseHeight: number

    The maps base height of a tile in pixels. Tiled maps support multiple tileset sizes within one map, but they are still placed at intervals of the base tile size.

    baseWidth: number

    The maps base width of a tile in pixels. Tiled maps support multiple tileset sizes within one map, but they are still placed at intervals of the base tile size.

    bottom: number

    The bottom of the tile in pixels.

    Set in the updatePixelXY method.

    canCollide: boolean

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

    collideDown: boolean

    Whether the tile should collide with any object on the bottom side.

    This property is used by Arcade Physics only, however, you can also use it in your own checks.

    collideLeft: boolean

    Whether the tile should collide with any object on the left side.

    This property is used by Arcade Physics only, however, you can also use it in your own checks.

    collideRight: boolean

    Whether the tile should collide with any object on the right side.

    This property is used by Arcade Physics only, however, you can also use it in your own checks.

    collides: boolean

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

    collideUp: boolean

    Whether the tile should collide with any object on the top side.

    This property is used by Arcade Physics only, however, you can also use it in your own checks.

    collisionCallback: Function

    Tile collision callback.

    collisionCallbackContext: object

    The context in which the collision callback will be called.

    faceBottom: boolean

    Whether the tiles bottom edge is interesting for collisions.

    faceLeft: boolean

    Whether the tiles left edge is interesting for collisions.

    faceRight: boolean

    Whether the tiles right edge is interesting for collisions.

    faceTop: boolean

    Whether the tiles top edge is interesting for collisions.

    flipX: boolean

    The horizontally flipped state of the Game Object.

    A Game Object that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

    flipY: boolean

    The vertically flipped state of the Game Object.

    A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

    hasInterestingFace: boolean

    True if this tile has any interesting faces.

    height: number

    The height of the tile in pixels.

    index: number

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

    layer: LayerData

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

    physics: object

    An empty object where physics-engine specific information (e.g. bodies) may be stored.

    pixelX: number

    The x coordinate of the top left of this tile in pixels. This is relative to the top left of the layer this tile is being rendered within. This property does NOT factor in camera scroll, layer scale or layer position.

    pixelY: number

    The y coordinate of the top left of this tile in pixels. This is relative to the top left of the layer this tile is being rendered within. This property does NOT factor in camera scroll, layer scale or layer position.

    properties: any

    Tile specific properties. These usually come from Tiled.

    right: number

    The right of the tile in pixels.

    Set in the updatePixelXY method.

    rotation: number

    The rotation angle of this tile.

    tilemap: Tilemaps.Tilemap

    The tilemap that contains this Tile. This will only return null if accessed from a LayerData instance before the tile is placed within a TilemapLayer.

    tilemapLayer: TilemapLayer

    The tilemap layer that contains this Tile. This will only return null if accessed from a LayerData instance before the tile is placed within a TilemapLayer.

    tileset: Tileset

    The tileset that contains this Tile. This is null if accessed from a LayerData instance before the tile is placed in a TilemapLayer, or if the tile has an index that doesn't correspond to any of the maps tilesets.

    tint: number

    The tint to apply to this tile. Note: tint is currently a single color value instead of the 4 corner tint component on other GameObjects.

    tintFill: boolean

    The tint fill mode.

    false = An additive tint (the default), where vertices colors are blended with the texture. true = A fill tint, where the vertices colors replace the texture, but respects texture alpha.

    visible: boolean

    The visible state of the Game Object.

    An invisible Game Object will skip rendering, but will still process update logic.

    width: number

    The width of the tile in pixels.

    x: number

    The x map coordinate of this tile in tile units.

    y: number

    The y map coordinate of this tile in tile units.

    Methods

    • Check if the given x and y world coordinates are within this Tile. This does not factor in camera scroll, layer scale or layer position.

      Parameters

      • x: number

        The x coordinate to test.

      • y: number

        The y coordinate to test.

      Returns boolean

    • Copies the tile data and properties from the given Tile to this Tile. This copies everything except for position and interesting face calculations.

      Parameters

      • tile: Tile

        The tile to copy from.

      Returns this

    • The collision group for this Tile, defined within the Tileset. This returns a reference to the collision group stored within the Tileset, so any modification of the returned object will impact all tiles that have the same index as this tile.

      Returns object

    • The tile data for this Tile, defined within the Tileset. This typically contains Tiled collision data, tile animations and terrain information. This returns a reference to the tile data stored within the Tileset, so any modification of the returned object will impact all tiles that have the same index as this tile.

      Returns object

    • Check for intersection with this tile. This does not factor in camera scroll, layer scale or layer position.

      Parameters

      • x: number

        The x axis in pixels.

      • y: number

        The y axis in pixels.

      • right: number

        The right point.

      • bottom: number

        The bottom point.

      Returns boolean

    • Checks if the tile is interesting.

      Parameters

      • collides: boolean

        If true, will consider the tile interesting if it collides on any side.

      • faces: boolean

        If true, will consider the tile interesting if it has an interesting face.

      Returns boolean

    • Reset collision status flags.

      Parameters

      • OptionalrecalculateFaces: boolean

        Whether or not to recalculate interesting faces for this tile and its neighbors. Default true.

      Returns this

    • Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.

      Returns this

    • Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.

      Parameters

      • Optionalvalue: number

        The alpha value applied across the whole Game Object. Default 1.

      Returns this

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

      Parameters

      • left: boolean

        Indicating collide with any object on the left.

      • Optionalright: boolean

        Indicating collide with any object on the right.

      • Optionalup: boolean

        Indicating collide with any object on the top.

      • Optionaldown: boolean

        Indicating collide with any object on the bottom.

      • OptionalrecalculateFaces: boolean

        Whether or not to recalculate interesting faces for this tile and its neighbors. Default true.

      Returns this

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

      Parameters

      • callback: Function

        Callback function.

      • context: object

        Callback will be called within this context.

      Returns this

    • Sets the horizontal and vertical flipped state of this Game Object.

      A Game Object that is flipped will render inversed on the flipped axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

      Parameters

      • x: boolean

        The horizontal flipped state. false for no flip, or true to be flipped.

      • y: boolean

        The horizontal flipped state. false for no flip, or true to be flipped.

      Returns this

    • Sets the horizontal flipped state of this Game Object.

      A Game Object that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

      Parameters

      • value: boolean

        The flipped state. false for no flip, or true to be flipped.

      Returns this

    • Sets the vertical flipped state of this Game Object.

      Parameters

      • value: boolean

        The flipped state. false for no flip, or true to be flipped.

      Returns this

    • Sets the size of the tile and updates its pixelX and pixelY.

      Parameters

      • tileWidth: number

        The width of the tile in pixels.

      • tileHeight: number

        The height of the tile in pixels.

      • baseWidth: number

        The base width a tile in the map (in pixels).

      • baseHeight: number

        The base height of the tile in pixels (in pixels).

      Returns this

    • Sets the visibility of this Game Object.

      An invisible Game Object will skip rendering, but will still process update logic.

      Parameters

      • value: boolean

        The visible state of the Game Object.

      Returns this

    • Toggles the horizontal flipped state of this Game Object.

      A Game Object that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

      Returns this

    • Used internally. Updates the tiles world XY position based on the current tile size.

      Returns this