lib/particles.js
function(game, config) {
    var particleCount = Math.floor(random.inRange(config.qtyMin, config.qtyMax));
    for (var i = 0; i < particleCount; i++) {
      var particle = game.prefabs.instantiate(game.entities, config.prefab);
      // check if origin is an entity
      var origin = config.origin;
      if (typeof config.origin === "number") {
        origin = choosePointInEntity(game, origin);
      }

      var randomSize = random.inRange(config.sizeMin, config.sizeMax);
      scaleEntityRect(game, particle, randomSize);

      centerEntityOnPoint(game, particle, origin);

      var velocity = random.inRange(config.velocityMin, config.velocityMax);

      var angle = pickAngle(config, i, particleCount);
      var velocityComponent = game.entities.addComponent(particle, "velocity");
      var direction = pointOnCircle(angle, velocity);
      velocityComponent.x = direction.x;
      velocityComponent.y = direction.y;

      if (config.accelerationX || config.accelerationY) {
        var accel = game.entities.addComponent(particle, "acceleration");
        accel.x = config.accelerationX;
        accel.y = config.accelerationY;
      }
      var lifeSpan = game.entities.addComponent(particle, "lifeSpan");
      lifeSpan.max = random.inRange(config.lifeSpanMin, config.lifeSpanMax);
    }
  }
function(game, config) {
    var particleCount = Math.floor(random.inRange(config.qtyMin, config.qtyMax));
    for (var i = 0; i < particleCount; i++) {
      var particle = game.prefabs.instantiate(game.entities, config.prefab);
      // check if origin is an entity
      var origin = config.origin;
      if (typeof config.origin === "number") {
        origin = choosePointInEntity(game, origin);
      }

      var randomSize = random.inRange(config.sizeMin, config.sizeMax);
      scaleEntityRect(game, particle, randomSize);

      centerEntityOnPoint(game, particle, origin);

      var velocity = random.inRange(config.velocityMin, config.velocityMax);

      var angle = pickAngle(config, i, particleCount);
      var velocityComponent = game.entities.addComponent(particle, "velocity");
      var direction = pointOnCircle(angle, velocity);
      velocityComponent.x = direction.x;
      velocityComponent.y = direction.y;

      if (config.accelerationX || config.accelerationY) {
        var accel = game.entities.addComponent(particle, "acceleration");
        accel.x = config.accelerationX;
        accel.y = config.accelerationY;
      }
      var lifeSpan = game.entities.addComponent(particle, "lifeSpan");
      lifeSpan.max = random.inRange(config.lifeSpanMin, config.lifeSpanMax);
    }
  }
function ( game , config ) { var particleCount = Math . floor ( random . inRange ( config . qtyMin , config . qtyMax ) ) ; for ( var i = 0 ; i < particleCount ; i ++ ) { var particle = game . prefabs . instantiate ( game . entities , config . prefab ) ; // check if origin is an entity var origin = config . origin ; if ( typeof config . origin === "number" ) { origin = choosePointInEntity ( game , origin ) ; } var randomSize = random . inRange ( config . sizeMin , config . sizeMax ) ; scaleEntityRect ( game , particle , randomSize ) ; centerEntityOnPoint ( game , particle , origin ) ; var velocity = random . inRange ( config . velocityMin , config . velocityMax ) ; var angle = pickAngle ( config , i , particleCount ) ; var velocityComponent = game . entities . addComponent ( particle , "velocity" ) ; var direction = pointOnCircle ( angle , velocity ) ; velocityComponent . x = direction . x ; velocityComponent . y = direction . y ; if ( config . accelerationX || config . accelerationY ) { var accel = game . entities . addComponent ( particle , "acceleration" ) ; accel . x = config . accelerationX ; accel . y = config . accelerationY ; } var lifeSpan = game . entities . addComponent ( particle , "lifeSpan" ) ; lifeSpan . max = random . inRange ( config . lifeSpanMin , config . lifeSpanMax ) ; } }
Create between {@link module:splat-ecs/lib/particles.Config#qtyMin qtyMin} and {@link module:splat-ecs/lib/particles.Config#qtyMax qtyMax} particles, and randomize their properties according to <code>config</code>.
@param {object} game The <code>game</code> object that you get in systems and scripts.
@param {module:splat-ecs/lib/particles.Config} config The settings to use to create the particles.
Create between {