Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Delay

A way to keep track of a delay. Useful when you want some event to occur every X milliseconds, for example.

param

Arguments to this delay.

param

The number of milliseconds between events. You can specify an array of numbers to have the even trigger at non-equal intervals.

param

If specified, a minimum amount of variance for the event. May be negative, but should be larger than the smallest value specified in millis.

param

If specified, a maximum amount of variance for the event.

param

If specified and true, this timer will automatically repeat and isDone() will never return true.

param

This argument is only honored if args.loop is defined and true. If true, this argument is the number of times to loop; if this argument is not specified, looping will occur indefinitely.

param

If specified, a callback function that will be called when this delay fires.

constructor

Hierarchy

  • Delay

Index

Constructors

constructor

  • Parameters

    Returns Delay

Properties

_callback

_callback: Function

_curInitial

_curInitial: number

_initial

_initial: number[]

_initialIndex

_initialIndex: number

_loop

_loop: boolean

_loopCount

_loopCount: number

_maxDelta

_maxDelta: number

_maxLoopCount

_maxLoopCount: number

_minDelta

_minDelta: number

_remaining

_remaining: number

Methods

getLoopCount

  • getLoopCount(): number
  • Returns the number of times this Delay has looped.

    Returns number

    The number of times this Delay has looped.

getMaxDelta

  • getMaxDelta(): number
  • Returns the maximum delta value, or -1 if none was defined.

    see

    getMinDelta()

    Returns number

    The maximum delta value.

getMinDelta

  • getMinDelta(): number
  • Returns the minimum delta value, or -1 if none was defined.

    see

    getMaxDelta()

    Returns number

    The minimum delta value.

getRemaining

  • getRemaining(): number
  • Returns the remaining time on this delay.

    Returns number

    The remaining time on this delay.

getRemainingPercent

  • getRemainingPercent(): number
  • Returns how far along we are in this delay, in the range 0 - 1.

    Returns number

    How far along we are in this delay.

isDone

  • isDone(): boolean
  • Returns whether this Delay has completed.

    Returns boolean

    Whether this Delay has completed.

reset

  • reset(smooth?: boolean): void
  • Parameters

    • Optional smooth: boolean

    Returns void

setRandomDelta

  • setRandomDelta(min: number, max: number): void
  • Causes this delay to trigger with a little random variance.

    Parameters

    • min: number

      The minimum possible variance, inclusive.

    • max: number

      The maximum possible variance, exclusive.

    Returns void

toString

  • toString(): string
  • Returns string

update

  • update(delta: number): boolean
  • Should be called in the update() method of the current game state to update this Delay.

    Parameters

    • delta: number

      The time that has elapsed since the last call to this method.

    Returns boolean

Generated using TypeDoc