Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Effect

[24:7] extends: FxObj

Wraps an AussomEffect (subclass of FXGL's abstract Effect) so Aussom code can define custom temporary entity effects. The Effect lives for a fixed duration once applied via EffectComponent.startEffect. Example: e = new Effect(3.0); e.onStart(::startGlow); e.onEnd(::endGlow); ec.startEffect(e); public startGlow(entity) { ... } public endGlow(entity) { ... }

Methods

  • Effect (double DurationSeconds = 1.0)

    Creates a new Effect with the given duration in seconds. Use onStart / onUpdate / onEnd to wire callbacks before passing the effect to EffectComponent.startEffect.

    • @p DurationSeconds is the effect lifetime in seconds.
  • adopt (object Ajo)

    Wraps an existing Effect AussomJavaObject.

  • onStart (callback Cb)

    Registers the onStart callback (fires once when the effect is applied to its Entity). The callback receives the Entity.

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

    Registers the onUpdate callback (fires every tick while the effect is active). The callback receives (entity, tpf).

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

    Registers the onEnd callback (fires once when the effect ends, either by timeout or explicit endEffect). The callback receives the Entity.

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

    Returns true once the effect's duration has elapsed.