Options
All
  • Public
  • Public/Protected
  • All
Menu

An extended Sprite that adds frame data, animations, and tile size.

Hierarchy

Index

Constructors

constructor

Properties

alpha

alpha: number

The opacity of the entity (from 0 to 1)

anims

anims: Animations

Animations used by the sprite.

children

children: Partial<Entity>[]

An array of child entities for recursive update/render.

dead

dead: boolean

Whether or not the entity is dead.

frame

frame: any | Point

The frame data. Should always have x and y properties.

hitBox

hitBox: HitBox

The hitbox of the sprite.

pos

pos: Vec

Position of the entity.

rotation

rotation: number

The rotation of the sprite.

scale

scale: Vec

Scale of the entity.

tileHeight

tileHeight: number

Height of the sprite in pixels

tileWidth

tileWidth: number

Width of the sprite in pixels

visible

visible: boolean

Whether or not the entity is visible.

Accessors

anchor

  • get anchor(): Vec

hasChildren

  • get hasChildren(): boolean

height

  • get height(): number

pivot

  • get pivot(): Vec

texture

width

  • get width(): number

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

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

update

  • update(dt: number, _: number): void
  • Update the animations.

    Parameters

    • dt: number

      Delta time since last update.

    • _: number

      Not used

    Returns void