Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Timer

[17:7] extends: FxObj

Wraps FXGL's Timer service that drives every TimerAction in a scene. Aussom users construct a Timer (or obtain the engine timer through fxgl.getGameTimer in chunk 6) and schedule callbacks with runOnceAfter (single-shot delay) or runAtInterval (repeating). Each scheduling call returns a TimerAction the caller can pause / resume / expire later.

Methods

  • Timer (Ajo = null)

    Creates a Timer wrapper. With no argument constructs a new FXGL Timer; with an AussomJavaObject wraps an existing one (used by fxgl.getGameTimer).

    • @p Ajo is an optional AussomJavaObject around an FXGL Timer.
  • adopt (object Ajo)

    Wraps an existing Timer AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an FXGL Timer.
    • @r A new wrapper.
  • runOnceAfter (callback Cb, double Seconds)

    Schedules a callback to run after the given delay in seconds.

    • @p Cb is a callback with no arguments.
    • @p Seconds is the delay before firing.
    • @r A TimerAction wrapper.
  • runAtInterval (callback Cb, double Seconds)

    Schedules a callback to run every Seconds, indefinitely.

    • @p Cb is a callback with no arguments.
    • @p Seconds is the interval between firings.
    • @r A TimerAction wrapper.
  • runAtIntervalLimited (callback Cb, double Seconds, int Limit)

    Schedules a callback to run every Seconds for Limit total firings, after which the TimerAction expires.

    • @p Cb is a callback with no arguments.
    • @p Seconds is the interval.
    • @p Limit is the total number of firings.
    • @r A TimerAction wrapper.
  • newLocalTimer ()

    Returns a new LocalTimer for capture / elapsed checks.

    • @r A LocalTimer wrapper.
  • update (double Tpf)

    Drives the timer one tick forward. Normally called by the scene; available for manual driving in tests.

    • @p Tpf is the elapsed time in seconds.
    • @r this object
  • getNow ()

    Returns the accumulated elapsed time in seconds since the Timer started.

    • @r A double in seconds.
  • clear ()

    Cancels every scheduled TimerAction.

    • @r this object
  • runAtIntervalWhile (callback Cb, double Seconds, object ConditionObj)

    Schedules a callback to run every Seconds for as long as the supplied BooleanProperty stays true. Useful for "fire while shield up" style mechanics.

    • @p Cb is the callback (no arguments).
    • @p Seconds is the interval.
    • @p ConditionObj is an AussomJavaObject around a ReadOnlyBooleanProperty.
    • @r A TimerAction wrapper.