Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "timers"

Index

Interfaces

Functions

Functions

animation

  • animation(callback: (dt: number) => any): Timer
  • Creates a timer based on requestAnimationFrame that calls callback every frame, with the delta in milliseconds since the last frame.

    Parameters

    • callback: (dt: number) => any
        • (dt: number): any
        • Parameters

          • dt: number

          Returns any

    Returns Timer

interpolate

  • interpolate(duration: number, callback: (t: number) => any): Timer
  • Creates a timer that calls callback once every frame until duration milliseconds have elapsed.

    callback is called with the normalized progress (0-1) between the start and the end.

    This timer is designed to be used with the easing module to create tweens and animations.

    Parameters

    • duration: number

      Length of the interpolation in milliseconds

    • callback: (t: number) => any

      Function that will be called each frame

        • (t: number): any
        • Parameters

          • t: number

          Returns any

    Returns Timer

interval

  • interval(duration: number, callback: (dt: number) => any): Timer
  • Creates a timer that calls callback once every duration milliseconds.

    An alternative to setInterval that won't run in the background.

    The interval timer can be used to create fixed rate animation loops.

    // call update at 30fps
    Timers.interval(1000 / 30, update);

    Parameters

    • duration: number

      Length of the interval in milliseconds

    • callback: (dt: number) => any

      Callback which is called with the delta in milliseconds between the current call and the last one.

        • (dt: number): any
        • Parameters

          • dt: number

          Returns any

    Returns Timer

timeout

  • timeout(duration: number, callback: () => any): Timer
  • Creates a timer that calls callback after duration milliseconds have elapsed.

    An alternative to setTimeout that won't run in the background.

    Parameters

    • duration: number

      Duration in milliseconds

    • callback: () => any

      Function to call when the timeout completes

        • (): any
        • Returns any

    Returns Timer

Generated using TypeDoc