Skip to content
nhmkdev edited this page Jan 5, 2014 · 2 revisions

Definition

The Particle system is used to show particles based on the data specified

Container

Particle Data

var Particles = ig.global.data.particles;

Particle Object

var Particle = ig.global.support.particle;

Data Format

Ranges

The Particles object supports ranges and values in a number of the fields:

  • n (number of particles/pieces)
  • fr (frame range)
  • vx, vy (x/y velocity)
  • l (lifetime)

These fields can be assigned a number or an object with a min and max field: {min:0, max:1} to specify a range. This allows for some variety when the given particle is spawned.

Format

Particles.sample =
{
    n:{min:6, max:12}, // number of particles
    l:{min:0.75, max: 2}, // lifetime of particles
    vx: {min:20, max:100}, // velocity x
    vy: {min:-75, max:150}, // velocity y

    g:1, //gravity factor (default: 1)
    i:'particles', // image name ('media/' is prepended and '.png' is appended)
    w:2, // width of frame
    h:2, // height of frame
    f:{x:100, y: 0}, // friction (default: {x:0, y:0})
    b:0, // bounciness
    fr: {min:0, max:1} // frames of the image to include (default is all) -- max is not included! (due to array indexing)
}

#Usage

Example from the Projectile entity:

Particle.spawn(this.pos.x + (this.flip ? -15 : 15), this.pos.y, { flip: this.flip, p:Particles.sample});

Clone this wiki locally