Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

Index

Constructors

Properties

active: boolean = true

Whether this entity is active, if set to false it will be reclaimed

childrenAdded$: Util.Observable<Entity> = ...
childrenRemoved$: Util.Observable<Entity> = ...
componentAdded$: Util.Observable<AddedComponent> = ...

Observable that keeps track of component add or remove changes on the entity

componentRemoved$: Util.Observable<RemovedComponent> = ...
data: Map<string, any> = ...

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

eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

height: number

Height of the tile in pixels

id: number = ...

The unique identifier for the entity

map: TileMap

Reference to the TileMap this tile is associated with

width: number

Width of the tile in pixels

x: number

Integer x coordinate of the tile

y: number

Integer y coordinate of the tile

Accessors

  • get children(): readonly Entity[]
  • get isInitialized(): boolean
  • get name(): string
  • 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

  • get tags(): readonly string[]
  • get types(): string[]

Methods

  • _initialize(engine: Engine): void
  • Initializes this entity, meant to be called by the Scene before first update not by users of Excalibur.

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    internal

    Parameters

    Returns void

  • _postupdate(engine: Engine, delta: number): void
  • _preupdate(engine: Engine, delta: number): void
  • _setName(name: string): void
  • 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

  • addComponent<T>(component: T, force?: boolean): Entity
  • addTemplate(templateEntity: Entity, force?: boolean): Entity
  • Adds a copy of all the components from another template entity as a "prefab"

    Parameters

    • templateEntity: Entity

      Entity to use as a template

    • force: boolean = false

      Force component replacement if it already exists on the target entity

    Returns Entity

  • clearColliders(): void
  • clearGraphics(): void
  • emit(eventName: string, eventObject: any): void
  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • flagDirty(): boolean
  • has<T>(type: ComponentCtor<T>): boolean
  • has(type: string): boolean
  • hasTag(tag: string): boolean
  • isKilled(): boolean
  • kill(): void
  • off(eventName: string, handler?: (event: any) => void): void
  • Alias for removeEventListener. If only the eventName is specified it will remove all handlers registered for that specific event. If the eventName and the handler instance are specified only that handler will be removed.

    Parameters

    • eventName: string

      Name of the event to listen for

    • Optional handler: (event: any) => void

      Event handler for the thrown event

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • on(eventName: string, handler: (event: any) => void): void
  • Alias for addEventListener. You can listen for a variety of events off of the engine; see the events section below for a complete list.

    Parameters

    • eventName: string

      Name of the event to listen for

    • handler: (event: any) => void

      Event handler for the thrown event

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • onInitialize(_engine: Engine): void
  • onPostUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('postupdate', (evt) =>{...})

    onPostUpdate is called directly after an entity is updated.

    Parameters

    Returns void

  • onPreUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPreUpdate is called directly before an entity is updated.

    Parameters

    Returns void

  • once(eventName: string, handler: (event: any) => void): void
  • Once listens to an event one time, then unsubscribes from that event

    Parameters

    • eventName: string

      The name of the event to subscribe to once

    • handler: (event: any) => void

      The handler of the event that will be auto unsubscribed

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • removeCollider(collider: Collider): void
  • removeComponent<ComponentOrType>(componentOrType: ComponentOrType, force?: boolean): Entity
  • Removes a component from the entity, by default removals are deferred to the end of entity update to avoid consistency issues

    Components can be force removed with the force flag, the removal is not deferred and happens immediately

    Type parameters

    Parameters

    • componentOrType: ComponentOrType
    • force: boolean = false

    Returns Entity

  • removeGraphic(graphic: Graphic): void
  • removeTag(tag: string, force?: boolean): Entity
  • unparent(): void
  • update(engine: Engine, delta: number): void