Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Component

[22:7] extends: FxObj

Wraps an AussomComponent (subclass of FXGL Component) so Aussom users can define entity behaviors with onAdded / onUpdate / onRemoved callbacks. Attach the resulting Component to an Entity via entity.addComponent. Example: c = new Component(); c.onUpdate(::tick); entity.addComponent(c); public tick(tpf) { ... }

Methods

  • Component ()

    Creates a new AussomComponent. Use onAdded / onUpdate / onRemoved to wire callbacks before attaching to an Entity.

  • onAdded (callback Cb)

    Registers the onAdded callback (fires once when the component is attached to its Entity). The callback receives the Entity.

    • @p Cb is a callback that takes an Entity argument.
    • @r this object
  • onUpdate (callback Cb)

    Registers the onUpdate callback (fires every frame the component is active). The callback receives the tpf in seconds.

    • @p Cb is a callback that takes a double tpf.
    • @r this object
  • onRemoved (callback Cb)

    Registers the onRemoved callback (fires once when the component is detached). The callback receives the Entity.

    • @p Cb is a callback that takes an Entity argument.
    • @r this object
  • getEntity ()

    Returns the Entity this component is attached to (null until addComponent is called).

    • @r An AussomJavaObject around an Entity, or null.
  • pause ()

    Pauses this component (onUpdate no longer fires).

    • @r this object
  • resume ()

    Resumes a paused component.

    • @r this object
  • isPaused ()

    Returns whether the component is paused.

    • @r A bool.
  • pausedProperty ()

    Returns the BooleanProperty mirroring the paused flag. Bind UI elements to this property to react when a component pauses or resumes.