Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ParticleComponent

[21:7] extends: Component

Wraps FXGL's ParticleComponent, the component that drives a ParticleEmitter from an Entity. Attach to an entity that should emit particles centered on its position. The component automatically registers with the entity's GameWorld and renders particles independently of the entity's view (so moving the entity does not drag previously-emitted particles). Use onFinished to run a callback when the emitter exhausts its max-emissions limit (no-op for unbounded emitters).

Methods

  • ParticleComponent (EmitterObj = null)

    Creates a new ParticleComponent driving the given emitter. Pass nothing (or null) to construct an empty wrapper that adopt() will later populate; FXGL's underlying ParticleComponent constructor requires a non-null emitter and is only invoked when EmitterObj is supplied.

    • @p EmitterObj is a ParticleEmitter wrapper, or null.
  • adopt (object Ajo)

    Wraps an existing ParticleComponent AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a ParticleComponent.
    • @r A new wrapper.
  • setOnFinished (callback Cb)

    Registers a callback that fires when the emitter finishes its configured max-emissions.

    • @p Cb is a callback with no arguments.
    • @r this object
  • isEmitterPaused ()

    Returns whether the underlying emitter is paused.

    • @r A bool.
  • pauseEmitter ()

    Pauses emission. Existing particles continue their life cycle; new particles stop spawning.

    • @r this object
  • resumeEmitter ()

    Resumes a paused emitter.

    • @r this object
  • getEmitter ()

    Returns the wrapped emitter as a ParticleEmitter wrapper. Useful for tweaking emission parameters at runtime.

    • @r A ParticleEmitter wrapper.
  • getOnFinished ()

    Returns the on-finished Runnable AJO registered via setOnFinished (or null when unset).

  • getParent ()

    Returns the parent Entity wrapper (or null when this component is not yet attached).