as defined in the Name field of the Object Properties (in Tiled)
corresponding Class to be instantiated
Optionalrecycling: boolean = falseenables object recycling for the specified class
// implement CherryEntity
class Cherry extends Sprite {
onResetEvent() {
// reset object mutable properties
this.lifeBar = 100;
}
};
// add our users defined entities in the object pool and enable object recycling
// this also registers "cherrysprite" as a Tiled object factory, so any object
// with class or name "cherrysprite" in a Tiled map will create a Cherry instance
me.pool.register("cherrysprite", Cherry, true);
Register an object to the pool.
Pooling must be set to true if more than one such objects will be created.
(Note: for an object to be poolable, it must implement an
onResetEventmethod)Registered classes are also automatically available as Tiled object factories, meaning objects placed in a Tiled map with a matching class or name will be instantiated using the registered constructor. For more control, use registerTiledObjectClass or registerTiledObjectFactory instead.