melonjs
    Preparing search index...

    Function pull

    • Pull a new instance of the requested object (if added into the object pool)

      Parameters

      • name: string

        as used in pool.register

      • Optional...args: any[]

        arguments to be passed when instantiating/reinitializing the object

      Returns object

      the instance of the requested object

      me.pool.register("bullet", BulletEntity, true);
      me.pool.register("enemy", EnemyEntity, true);
      // ...
      // when we need to manually create a new bullet:
      let bullet = me.pool.pull("bullet", x, y, direction);
      // ...
      // params aren't a fixed number
      // when we need new enemy we can add more params, that the object construct requires:
      let enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
      // ...
      // when we want to destroy existing object, the remove
      // function will ensure the object can then be reallocated later
      me.game.world.removeChild(enemy);
      me.game.world.removeChild(bullet);