Skip to main content

Tile

TileMap Tile

A light-weight object that occupies a space in a collision map. Generally created by a [[TileMap]].

Tiles can draw multiple sprites. Note that the order of drawing is the order of the sprites in the array so the last one will be drawn on top. You can use transparency to create layers this way.

Index

Constructors

constructor

Properties

publicdata

data: Map<string, any> = ...

Arbitrary data storage per tile, useful for any game specific data

publicevents

publicmap

map: TileMap

Reference to the TileMap this tile is associated with

publicreadonlyx

x: number

Integer x coordinate of the tile

publicreadonlyy

y: number

Integer y coordinate of the tile

Accessors

publicbounds

publiccenter

  • Tile position in world space


    Returns Vector

publicdefaultGeometry

publicheight

  • get height(): number
  • Height of the tile in pixels


    Returns number

publicpos

  • Return the world position of the top left corner of the tile


    Returns Vector

publicsolid

  • get solid(): boolean
  • set solid(val: boolean): void
  • Wether this tile should be treated as solid by the tilemap


    Returns boolean

  • Wether this tile should be treated as solid by the tilemap


    Parameters

    • val: boolean

    Returns void

publicwidth

  • get width(): number
  • Width of the tile in pixels


    Returns number

Methods

publicaddCollider

  • Adds a custom collider to the [[Tile]] to use instead of it's bounds

    If no collider is set but [[Tile.solid]] is set, the tile bounds are used as a collider.

    Note! the [[Tile.solid]] must be set to true for it to act as a "fixed" collider


    Parameters

    Returns void

publicaddGraphic

  • addGraphic(graphic: Graphic, options?: { offset?: Vector }): void
  • Add another [[Graphic]] to this TileMap tile


    Parameters

    Returns void

publicclearColliders

  • clearColliders(): void
  • Clears all colliders from the [[Tile]]


    Returns void

publicclearGraphics

  • clearGraphics(): void
  • Clear all graphics from this tile


    Returns void

publicemit

  • emit<TEventName>(eventName: TEventName, event: TilePointerEvents[TEventName]): void
  • emit(eventName: string, event?: any): void

publicflagDirty

  • flagDirty(): boolean
  • Returns boolean

publicgetColliders

  • Returns the list of colliders


    Returns readonly Collider[]

publicgetGraphics

  • Current list of graphics for this tile


    Returns readonly Graphic[]

publicgetGraphicsOffsets

  • getGraphicsOffsets(): readonly Vector[]
  • Current list of offsets for this tile's graphics


    Returns readonly Vector[]

publicoff

  • off<TEventName>(eventName: TEventName, handler: Handler<TilePointerEvents[TEventName]>): void
  • off(eventName: string, handler: Handler<unknown>): void
  • off(eventName: string): void

publicon

publiconce

publicremoveCollider

  • removeCollider(collider: Collider): void
  • Removes a collider from the [[Tile]]


    Parameters

    Returns void

publicremoveGraphic

  • removeGraphic(graphic: Graphic): void
  • Remove an instance of a [[Graphic]] from this tile


    Parameters

    Returns void