Options
All
  • Public
  • Public/Protected
  • All
Menu

A customized Container of TileSprite objects that provides helper methods for accessing tiles.

Only tiles on the 'level' layer are used. Other layers are only for display.

Hierarchy

Index

Constructors

constructor

Properties

alpha

alpha: number

The opacity of the entity (from 0 to 1)

children

children: Partial<Entity>[]

An array of child entities for recursive update/render.

dead

dead: boolean

Whether or not the entity is dead.

levelIndex

levelIndex: number

Index of the level layer in tiles data.

mapHeight

mapHeight: number

Height of the entire map in tiles.

mapWidth

mapWidth: number

Width of the entire map in tiles.

pos

pos: Vec

Position of the entity.

scale

scale: Vec

Scale of the entity.

tileHeight

tileHeight: number

Height of one tile in pixels.

tileWidth

tileWidth: number

Width of one tile in pixels.

visible

visible: boolean

Whether or not the entity is visible.

Accessors

hasChildren

  • get hasChildren(): boolean

layersAboveLevel

  • get layersAboveLevel(): Partial<Entity>[]

layersUpToLevel

  • get layersUpToLevel(): Partial<Entity>[]
  • Gets the layers up to and including the level layer.

    Returns Partial<Entity>[]

Methods

add

  • add<T>(child: T): T
  • Add and return a child object.

    Type parameters

    • T

    Parameters

    • child: T

      Object to add to the container.

    Returns T

map

  • map(fn: (child: Partial<Entity>, index?: number) => void): any
  • Map a function across all children.

    Parameters

    • fn: (child: Partial<Entity>, index?: number) => void

      Function to call for each child.

        • (child: Partial<Entity>, index?: number): void
        • Parameters

          • child: Partial<Entity>
          • Optional index: number

          Returns void

    Returns any

mapToPixelPos

  • mapToPixelPos(mapPos: Vec): Vec
  • Converts a map tile location to a pixel location.

    Parameters

    • mapPos: Vec

      Map location to convert.

    Returns Vec

    Vec Top-left corner pixel coordinate.

pixelToMapPos

  • pixelToMapPos(pos: Vec): Vec
  • Converts a pixel location to a map tile location.

    Parameters

    • pos: Vec

      Pixel location to convert.

    Returns Vec

remove

  • remove<T>(child: T): T
  • Remove and return a child object.

    Type parameters

    • T

    Parameters

    • child: T

      Object to remove from the container.

    Returns T

setTileFrameAtMapPos

  • Gets the tile at the specified location and sets the frame property.

    Parameters

    • mapPos: Vec

      Tile location to lookup tile.

    • frame: Point

      The frame to set on the tile.

    Returns TileSprite

setTileFrameAtPixelPos

  • Gets the tile at the specified location and sets the frame property.

    Parameters

    • pos: Vec

      Pixel location to lookup tile.

    • frame: Point

      The frame to set on the tile.

    Returns TileSprite

tileAtMapPos

  • Gets the tile at the specified location.

    Parameters

    • mapPos: Vec

      Tile location to lookup tile.

    Returns TileSprite

tileAtPixelPos

tilesAtCorners

  • Gets the tiles at all four corners of the specified HitBox.

    Parameters

    • box: HitBox

      HitBox to test for corner tiles.

    • Default value xo: number = 0

      X axis offset to check against.

    • Default value yo: number = 0

      Y axis offset to check against.

    Returns TileSprite[]

update

  • update(dt: number, t: number): void
  • Update each child in the container.

    Automatically removes any child object marked as dead.

    Parameters

    • dt: number

      Delta time since last update.

    • t: number

      Timestamp in seconds.

    Returns void