Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: EventBuilder

[25:7] extends: FxObj

Wraps FXGL's EventBuilder (com.almasb.fxgl.dsl.EventBuilder), the fluent setup for firing a JavaFX Event onto the FXGL EventBus on a timer + a condition. Construct via fxgl.eventBuilder(). Wiring: eb = fxgl.eventBuilder(); eb.interval(durationAjo) .whenCondition(::shouldFire) .limit(5) .thenRun(::doIt) .buildAndStart(); Returns a TimerAction AJO that callers can later expire.

Methods

  • EventBuilder (Ajo = null)

    Wraps an existing EventBuilder AussomJavaObject (the usual entry, since fxgl.eventBuilder() returns a wrapper with the AJO already populated).

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

    Wraps an existing EventBuilder AussomJavaObject.

  • interval (object DurationAjo)

    Sets the interval between event fires. Default is zero (fire on every game tick).

    • @p DurationAjo is a javafx.util.Duration AJO (e.g. aji.invokeStaticRaw("javafx.util.Duration","seconds",1.0)).
  • whenCondition (callback Cb)

    Sets the predicate that decides whether to fire on each eligible tick. Named whenCondition rather than when to keep the call site free of reserved-word ambiguity in future Aussom grammars; matches FXGL's when(...) method.

    • @p Cb is a callback () -> bool.
  • limit (int Times)

    Sets the maximum number of events to emit before the underlying TimerAction expires. Must be > 0.

  • thenRun (callback Cb)

    Runs the given callback every time the condition fires. (Under the hood FXGL still pushes a FunctionCallEvent onto the EventBus, so global event listeners stay coherent.)

    • @p Cb is a callback () -> void.
  • thenFire (object EventAjo)

    Fires the given JavaFX Event each time the condition is met.

    • @p EventAjo is a javafx.event.Event AJO.
  • thenFireSupplier (callback Cb)

    Fires the event produced by the supplier each time the condition is met (use this form when each fire should carry fresh data).

    • @p Cb is a callback () -> javafx.event.Event AJO.
  • buildAndStart ()

    Starts the timer using the running game's EventBus + Timer and returns the TimerAction AJO.

  • buildAndStartOn (object EventBusObj, object TimerObj)

    Starts the timer against an explicit EventBus + Timer.

    • @p EventBusObj is an EventBus wrapper (or raw AJO).
    • @p TimerObj is a Timer wrapper (or raw AJO).