-
Notifications
You must be signed in to change notification settings - Fork 0
Particle
nhmkdev edited this page Jan 5, 2014
·
2 revisions
The Particle system is used to show particles based on the data specified
var Particles = ig.global.data.particles;
var Particle = ig.global.support.particle;
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.
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});