Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ComponentListener

[26:7] extends: FxObj

Wraps FXGL's ComponentListener two-method interface (com.almasb.fxgl.entity.component.ComponentListener). Fires onAdded(component) when a Component is added to the entity it's watching, and onRemoved(component) when one is removed. Backed by AussomComponentListener because the interface has two methods (aji.closure only handles single-method functional interfaces). Register the listener via Entity.addComponentListener(listener.obj). Example: listener = new ComponentListener(::onAdded, ::onRemoved); e.addComponentListener(listener.obj); public onAdded(component) { ... } public onRemoved(component) { ... }

Methods

  • ComponentListener (callback OnAdded = null, callback OnRemoved = null)

    Creates a new ComponentListener with the given Aussom callbacks. Either may be null to ignore that event class.

    • @p OnAdded is a callback (component) -> any.
    • @p OnRemoved is a callback (component) -> any.
  • adopt (object Ajo)

    Wraps an existing ComponentListener AussomJavaObject.

  • onAdded (object ComponentObj)

    Triggers the onAdded callback. The engine normally drives this when a Component is attached to an Entity that has the listener registered.

  • onRemoved (object ComponentObj)

    Triggers the onRemoved callback.