nodePool
constnodePool: <T>(factory,options?) =>NodePool<T>
A pool of nodes made by factory and used again: get() a node (a free one, reset to how the factory made it, or a new one), release() it instead of destroying it. Worth it only when spawning many nodes a second; creating and destroying nodes is fine otherwise.
Type Parameters
Section titled “Type Parameters”T extends Node
Parameters
Section titled “Parameters”factory
Section titled “factory”() => T
options?
Section titled “options?”Returns
Section titled “Returns”NodePool<T>
Example
Section titled “Example”import { nodePool } from '@fabiplay/engine'const coins = nodePool(() => engine.shape({ type: 'circle', r: 16, fill: '#FBD46A' }), { max: 40 })const coin = layer.add(coins.get({ x: 200, y: -20 }))engine.tween(coin, { y: 740 }, 2, 'linear').then(() => coins.release(coin))