Added lots of particles examples.

This commit is contained in:
Richard Davey
2013-09-16 01:08:06 +01:00
parent 8c9a7c8bc7
commit e705509d29
9 changed files with 456 additions and 39 deletions
+27 -6
View File
@@ -86,6 +86,11 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
*/
this.particleDrag = new Phaser.Point();
/**
* The angular drag component of particles launched from the emitter if they are rotating.
*/
this.angularDrag = 0;
/**
* How often a particle is emitted in ms (if emitter is started with Explode == false).
*/
@@ -103,9 +108,9 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
this.lifespan = 2000;
/**
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
* How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
*/
this.bounce = 0;
this.bounce = new Phaser.Point();
/**
* Internal helper for deciding how many particles to launch.
@@ -204,7 +209,7 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
*
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
*/
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide) {
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {
if (typeof frames == 'undefined')
{
@@ -212,7 +217,12 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
}
quantity = quantity || this.maxParticles;
collide = collide || 0;
collide = collide || 0;
if (typeof collideWorldBounds == 'undefined')
{
collideWorldBounds = false;
}
var particle;
var i = 0;
@@ -250,6 +260,8 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
particle.body.allowCollision.none = true;
}
particle.body.collideWorldBounds = collideWorldBounds;
particle.exists = false;
particle.visible = false;
@@ -317,7 +329,15 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
this._explode = explode;
this.lifespan = lifespan;
this.frequency = frequency;
this._quantity += quantity;
if (explode)
{
this._quantity = quantity;
}
else
{
this._quantity += quantity;
}
this._counter = 0;
this._timer = this.game.time.now + frequency;
@@ -347,7 +367,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
particle.lifespan = this.lifespan;
particle.body.bounce.setTo(this.bounce, this.bounce);
particle.body.bounce.setTo(this.bounce.x, this.bounce.y);
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
{
@@ -386,6 +406,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
particle.body.drag.x = this.particleDrag.x;
particle.body.drag.y = this.particleDrag.y;
particle.body.angularDrag = this.angularDrag;
}