Options
All
  • Public
  • Public/Protected
  • All
Menu

An effect where the provided TileSprite or Rect (defaults to rectangle if not provided) is moved vertically from its starting position at the specified speed, and fades out over its duration.

Default behavior is moving up and fading out over 0.6 seconds.

Example

// Inside a 'gotPickup' or similar function
const coin = new TileSprite(texture, 48, 48)
coin.anims.add('spin', [5, 6, 7, 8].map(x => ({ x, y: 4 } as any)), .1)
coin.anims.play('spin')

const one = this.add<OneUp>(new OneUp(coin))
one.pos.copy(this.player.pos)

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • Initialize OneUp object.

    Parameters

    • Optional display: TileSprite | Rect

      TileSprite (or Rect) to use for display. Rectangle created if not provided.

    • Default value speed: number = 2

      Speed (and x-axis direction by numeric sign) to move from initial point.

    • Default value duration: number = 0.6

      Time in seconds to fade out.

    Returns OneUp

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.

pos

pos: Vec

Position of the entity.

scale

scale: Vec

Scale of the entity.

visible

visible: boolean

Whether or not the entity is visible.

Accessors

hasChildren

  • get hasChildren(): boolean

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, t: number): void
  • Update the state of the OneUp.

    Parameters

    • dt: number

      Delta time since last update.

    • t: number

      Timestamp in seconds.

    Returns void