Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Pools

[21:14] static extends: object

Helper for FXGL's Pools static utility (com.almasb.fxgl.core.pool.Pools), a libGDX-style object pool registry. Used to recycle high-frequency allocations (bullets, particles, short-lived events) by class. Usage: bullet = Pools.obtain("com.mygame.Bullet"); ... Pools.free(bullet); Custom Pool implementations can be registered via Pools.set(ClassName, PoolAjo).

Methods

  • obtain (string ClassName)

    Returns a pooled instance of the named class. The class must have a no-args constructor (the default ReflectionPool requirement) or a custom Pool must have been set via set first.

    • @p ClassName is the fully qualified class name.
    • @r An AussomJavaObject around the pooled instance.
  • free (object ObjAjo)

    Returns the object to its pool. No-op if the object's class has no registered pool.

    • @p ObjAjo is the object to return.
  • set (string ClassName, object PoolObj)

    Registers a custom Pool for the named class.

    • @p ClassName is the fully qualified class name.
    • @p PoolObj is an AussomJavaObject around a Pool.