Basics
Guides
API Reference
Basics
Guides
API Reference
[43:7] extends: FxObj
Wraps FXGL's EntityFactory marker interface
(com.almasb.fxgl.entity.EntityFactory). The upstream API is
annotation-driven (@Spawns("name") on each spawner method);
Aussom code cannot synthesize Java annotations, so the
wrapper takes a different path:
fxgl.entityFactory() — produces an empty
AussomEntityFactory marker.addSpawner(name, callback). The callback receives a
SpawnData wrapper and must return an Entity wrapper.attachTo(world).
The factory registers itself so
GameWorld.create's entityFactories.isNotEmpty()
check passes; AussomEntityFactoryHelper then installs
each spawner directly into the GameWorld's spawner map.
Spawners added after attachTo are installed immediately.
Spawners added before are buffered and flushed during
attachTo.
Wiring:
ef = fxgl.entityFactory();
ef.addSpawner("player", ::makePlayer);
ef.addSpawner("enemy", ::makeEnemy);
ef.attachTo(fxgl.getGameWorld());
...
fxgl.getGameWorld().spawn("player"); // calls makePlayer
where makePlayer(spawnData) returns an Entity wrapper.pendingNames
Buffered spawn names, flushed during attachTo.
pendingCbs
Buffered spawn callbacks, paired with pendingNames.
world
GameWorld wrapper this factory is attached to (null when detached).
EntityFactory (Ajo = null)
Wraps an existing AussomEntityFactory AJO (the usual entry, since
fxgl.entityFactory()returns a wrapper with the AJO already populated). Initialises empty buffers; spawners registered beforeattachToare held here and flushed on first attach.
Ajo is an optional AussomJavaObject around an AussomEntityFactory.adopt (object Ajo)
Wraps an existing EntityFactory AussomJavaObject.
addSpawner (string Name, callback Cb)
Registers a spawner under the given name. The callback receives a SpawnData wrapper and must return an Entity wrapper. When the factory is already attached to a GameWorld, the spawner is installed immediately; otherwise it is buffered and flushed during attachTo. Registering the same name twice replaces the prior callback (matches upstream's last-writer-wins semantics when a single factory is rescanned).
Name is the spawn name (use the same string in GameWorld.spawn(name, ...)).Cb is a callback (spawnData) -> Entity wrapper.this objectremoveSpawner (string Name)
Removes a previously registered spawner. No-op when the name was never registered or has already been removed. Works whether or not the factory is attached.
Name is the spawn name to remove.this objectattachTo (object WorldObj)
Attaches this factory to a GameWorld so spawn names resolve through it. Registers the underlying AussomEntityFactory with the world (satisfies the
entityFactories.isNotEmpty()check insideGameWorld.create) and flushes every buffered spawner. Calling attachTo a second time against the same world is harmless; calling it against a different world re-buffers the existing spawners onto the new world (the old world still has them — calldetach()first to clean up).
WorldObj is a GameWorld wrapper.this objectdetach ()
Removes every spawner this factory installed from the attached GameWorld and deregisters the factory itself. Spawners are NOT re-buffered — call addSpawner again before the next attach.
this objecthasSpawner (string Name)
Returns whether a spawner is registered under the given name on the attached GameWorld. Returns false when the factory is not attached.
Name is the spawn name.A bool.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.