file: CollectibleHandler.aus

class: CollectibleHandler

[26:7] extends: CollisionHandler

Wraps FXGL's CollectibleHandler (com.almasb.fxgl.dsl.handlers.CollectibleHandler), a CollisionHandler subclass that handles the common pattern of a collector picking up a collectible: optional sound is played, a callback runs, and the collectible is removed. Register with the running game's PhysicsWorld (fxgl.getPhysicsWorld().addCollisionHandler in chunk 6). Example: h = new CollectibleHandler("player", "coin", "pickup.wav", ::collectCoin); physicsWorld.addCollisionHandler(h.obj); public collectCoin(coin) { fxgl.inc("score", 1); }

Methods