PokéRogue
    Preparing search index...

    A Timer Event represents a delayed function call. It's managed by a Scene's Clock and will call its function after a set amount of time has passed. The Timer Event can optionally repeat - i.e. call its function multiple times before finishing, or loop indefinitely.

    Because it's managed by a Clock, a Timer Event is based on game time, will be affected by its Clock's time scale, and will pause if its Clock pauses.

    Index
    • Parameters

      • config: TimerEventConfig

        The configuration for the Timer Event, including its delay and callback.

      Returns TimerEvent

    args: any[]

    Additional arguments to be passed to the callback.

    callback: Function

    The callback that will be called when the TimerEvent occurs.

    callbackScope: object

    The scope in which the callback will be called.

    delay: number

    The delay in ms at which this TimerEvent fires.

    elapsed: number

    The time in milliseconds which has elapsed since the Timer Event's creation.

    This value is local for the Timer Event and is relative to its Clock. As such, it's influenced by the Clock's time scale and paused state, the Timer Event's initial #startAt property, and the Timer Event's #timeScale and #paused state.

    hasDispatched: boolean

    Whether the Timer Event's function has been called.

    When the Timer Event fires, this property will be set to true before the callback function is invoked and will be reset immediately afterward if the Timer Event should repeat. The value of this property does not directly influence whether the Timer Event will be removed from its Clock, but can prevent it from firing.

    loop: boolean

    True if this TimerEvent loops, otherwise false.

    paused: boolean

    Whether or not this timer is paused.

    repeat: number

    The total number of times this TimerEvent will repeat before finishing.

    repeatCount: number

    If repeating, this value contains the current countdown of how many repeats are still to come. It starts at the value of #repeat and counts down to zero each time the Timer Event fires.

    startAt: number

    The number of milliseconds into the elapsed time to start the Timer Event from. This allows a long-duration repeating Timer Event to fire sooner on its first iteration without affecting the duration of subsequent repeats.

    timeScale: number

    A time scale factor applied to the elapsed time used to update this Timer Event. Values greater than 1 will cause the event to fire sooner, while values less than 1 will delay it. This is independent of, and multiplied with, the Clock's own time scale.

    • Destroys all object references in the Timer Event, i.e. its callback, scope, and arguments.

      Normally, this method is only called by the Clock when it shuts down. As such, it doesn't stop the Timer Event. If called manually, the Timer Event will still be updated by the Clock, but it won't do anything when it fires.

      Returns void

    • Returns the local elapsed time for the current iteration of the Timer Event.undefined

      Returns number

      The local elapsed time in milliseconds.

    • Returns the local elapsed time for the current iteration of the Timer Event in seconds.undefined

      Returns number

      The local elapsed time in seconds.

    • Gets the progress of the timer overall, factoring in repeats.undefined

      Returns number

      The overall progress of the Timer Event, between 0 and 1.

    • Returns the time interval until the last iteration of the Timer Event.undefined

      Returns number

      The time interval in milliseconds.

    • Returns the time interval until the last iteration of the Timer Event in seconds.undefined

      Returns number

      The time interval in seconds.

    • Gets the progress of the current iteration, not factoring in repeats.undefined

      Returns number

      A number between 0 and 1 representing the current progress.

    • Returns the time interval until the next iteration of the Timer Event.undefined

      Returns number

      The time interval in milliseconds.

    • Returns the time interval until the next iteration of the Timer Event in seconds.undefined

      Returns number

      The time interval in seconds.

    • Returns the number of times this Timer Event will repeat before finishing.

      This should not be confused with the number of times the Timer Event will fire before finishing. A return value of 0 doesn't indicate that the Timer Event has finished running - it indicates that it will not repeat after the next time it fires.undefined

      Returns number

      How many times the Timer Event will repeat.

    • Forces the Timer Event to immediately expire, thus scheduling its removal in the next frame.

      Parameters

      • OptionaldispatchCallback: boolean

        If true, the function of the Timer Event will be called before its removal. Default false.

      Returns void

    • Completely reinitializes the Timer Event, regardless of its current state, according to a configuration object.

      Parameters

      Returns TimerEvent

      This TimerEvent object.