Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: EngineService

[28:7] extends: SerializableType

Wraps an AussomEngineService (subclass of FXGL's abstract EngineService) so Aussom code can register a service with FXGL's engine. Install via GameSettings.addEngineService before launch. The on* methods register Aussom callbacks for FXGL's lifecycle hooks. onUpdate and onGameUpdate receive a double tpf. onVarsInitialized and onGameReady receive a PropertyMap wrapper. onWrite and onRead receive a Bundle wrapper. The other hooks take no arguments. Example: svc = new EngineService(); svc.onInit(::initService); svc.onUpdate(::tick); settings.addEngineService(svc.obj);

Methods

  • EngineService ()

    Creates a new EngineService bridge ready to receive on* callbacks.

  • adopt (object Ajo)

    Wraps an existing AussomEngineService AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an AussomEngineService.
    • @r A new wrapper.
  • onInit (callback Cb)

    Registers the onInit callback (background thread, after dependency injection). The callback takes no arguments.

    • @p Cb is a callback () -> any.
    • @r this object
  • onMainLoopStarting (callback Cb)

    Registers the onMainLoopStarting callback (JavaFX thread, once before the main loop starts). The callback takes no arguments.

    • @p Cb is a callback () -> any.
    • @r this object
  • onVarsInitialized (callback Cb)

    Registers the onVarsInitialized callback (background thread, after initGameVars). The callback receives a PropertyMap wrapper.

    • @p Cb is a callback (vars) -> any.
    • @r this object
  • onGameReady (callback Cb)

    Registers the onGameReady callback (background thread, after initGame/initPhysics/initUI complete). The callback receives a PropertyMap wrapper.

    • @p Cb is a callback (vars) -> any.
    • @r this object
  • onUpdate (callback Cb)

    Registers the onUpdate callback (JavaFX thread, every tick in any scene). The callback receives a double tpf.

    • @p Cb is a callback (tpf) -> any.
    • @r this object
  • onGameUpdate (callback Cb)

    Registers the onGameUpdate callback (JavaFX thread, every tick only in the game scene). The callback receives a double tpf.

    • @p Cb is a callback (tpf) -> any.
    • @r this object
  • onGameReset (callback Cb)

    Registers the onGameReset callback (JavaFX thread, after the game scene resets). The callback takes no arguments.

    • @p Cb is a callback () -> any.
    • @r this object
  • onExit (callback Cb)

    Registers the onExit callback (just before engine exit). The callback takes no arguments.

    • @p Cb is a callback () -> any.
    • @r this object
  • onMainLoopPausing (callback Cb)

    Registers the onMainLoopPausing callback (just before the main loop is paused). The callback takes no arguments.

    • @p Cb is a callback () -> any.
    • @r this object
  • onMainLoopResumed (callback Cb)

    Registers the onMainLoopResumed callback (just after the main loop resumes). The callback takes no arguments.

    • @p Cb is a callback () -> any.
    • @r this object
  • onWrite (callback Cb)

    Registers the SerializableType.write callback. The callback receives a Bundle wrapper and writes state into it for persistence.

    • @p Cb is a callback (bundle) -> any.
    • @r this object
  • onRead (callback Cb)

    Registers the SerializableType.read callback. The callback receives a Bundle wrapper and restores state from it.

    • @p Cb is a callback (bundle) -> any.
    • @r this object
  • write (object BundleObj)

    Triggers the bridge's write callback with the supplied Bundle.

  • read (object BundleObj)

    Triggers the bridge's read callback with the supplied Bundle.