melonjs
    Preparing search index...

    Function register

    • 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 implements a onResetEvent method)

      Parameters

      • className: string

        as defined in the Name field of the Object Properties (in Tiled)

      • classObj: object

        corresponding Class to be instantiated

      • Optionalrecycling: boolean = false

        enables object recycling for the specified class

      Returns void

      // 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
      me.pool.register("cherrysprite", Cherry, true);