Skip to content

Commit

Permalink
Added 'noRotation' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewstart committed Jun 25, 2016
1 parent c1d2e7e commit b362817
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 26 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixi-particles",
"version": "1.6.7",
"version": "1.6.8",
"main": "dist/pixi-particles.min.js",
"dependencies": {
"pixi.js": "*"
Expand Down
2 changes: 1 addition & 1 deletion dist/modules/animated-particle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! pixi-particles 1.6.7 */
/*! pixi-particles 1.6.8 */
/**
* @module Animated Particle
* @namespace PIXI.particles
Expand Down
2 changes: 1 addition & 1 deletion dist/modules/animated-particle.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/modules/path-particle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! pixi-particles 1.6.7 */
/*! pixi-particles 1.6.8 */
/**
* @module Path Particle
* @namespace PIXI.particles
Expand Down
2 changes: 1 addition & 1 deletion dist/modules/path-particle.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 36 additions & 12 deletions dist/pixi-particles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! pixi-particles 1.6.7 */
/*! pixi-particles 1.6.8 */
/**
* @module Pixi Particles
* @namespace window
Expand Down Expand Up @@ -42,7 +42,7 @@ if(!Array.prototype.random)
return this[Math.floor(Math.random() * this.length)];
}
});
}
}
/**
* @module Pixi Particles
* @namespace PIXI.particles
Expand Down Expand Up @@ -86,7 +86,7 @@ if(!Array.prototype.random)
// Assign to global namespace
global.PIXI.particles = global.PIXI.particles || particles;

}());
}());
/**
* @module Pixi Particles
* @namespace PIXI.particles
Expand All @@ -108,7 +108,7 @@ if(!Array.prototype.random)
var DEG_TO_RADS = ParticleUtils.DEG_TO_RADS = Math.PI / 180;

ParticleUtils.useAPI3 = false;
// avoid the string replacement of '"1.6.7"'
// avoid the string replacement of '"1.6.8"'
var version = PIXI["VER"+"SION"];// jshint ignore:line
if(version && parseInt(version.substring(0, version.indexOf("."))) >= 3)
{
Expand Down Expand Up @@ -289,7 +289,7 @@ if(!Array.prototype.random)

PIXI.particles.ParticleUtils = ParticleUtils;

}(PIXI));
}(PIXI));
/**
* @module Pixi Particles
* @namespace PIXI.particles
Expand Down Expand Up @@ -532,8 +532,15 @@ if(!Array.prototype.random)
this.velocity.x = this.startSpeed;
this.velocity.y = 0;
ParticleUtils.rotatePoint(this.rotation, this.velocity);
//convert rotation to Radians from Degrees
this.rotation *= ParticleUtils.DEG_TO_RADS;
if (this.noRotation)
{
this.rotation = 0;
}
else
{
//convert rotation to Radians from Degrees
this.rotation *= ParticleUtils.DEG_TO_RADS;
}
//convert rotation speed to Radians from Degrees
this.rotationSpeed *= ParticleUtils.DEG_TO_RADS;
//set alpha to inital alpha
Expand Down Expand Up @@ -674,7 +681,7 @@ if(!Array.prototype.random)
{
this.rotation += this.rotationSpeed * delta;
}
else if(this.acceleration)
else if(this.acceleration && !this.noRotation)
{
this.rotation = Math.atan2(this.velocity.y, this.velocity.x);// + Math.PI / 2;
}
Expand Down Expand Up @@ -759,7 +766,7 @@ if(!Array.prototype.random)
PIXI.particles.Particle = Particle;

}(PIXI));


/**
* @module Pixi Particles
* @namespace PIXI.particles
Expand Down Expand Up @@ -886,15 +893,24 @@ if(!Array.prototype.random)
* @property {Number} maxStartRotation
*/
this.maxStartRotation = 0;
/**
* If no particle rotation should occur. Starting rotation will still
* affect the direction in which particles move. If the rotation speed
* is set, then this will be ignored.
* @property {Boolean} maxStartRotation
*/
this.noRotation = false;
/**
* The minimum rotation speed for a particle, in degrees per second.
* This only visually spins the particle, it does not change direction of movement.
* This only visually spins the particle, it does not change direction
* of movement.
* @property {Number} minRotationSpeed
*/
this.minRotationSpeed = 0;
/**
* The maximum rotation speed for a particle, in degrees per second.
* This only visually spins the particle, it does not change direction of movement.
* This only visually spins the particle, it does not change direction
* of movement.
* @property {Number} maxRotationSpeed
*/
this.maxRotationSpeed = 0;
Expand Down Expand Up @@ -1271,6 +1287,13 @@ if(!Array.prototype.random)
}
else
this.minStartRotation = this.maxStartRotation = 0;
if (config.noRotation &&
(this.minStartRotation || this.maxStartRotation))
{
this.noRotation = !!config.noRotation;
}
else
this.noRotation = false;
//set up the rotation speed
if (config.rotationSpeed)
{
Expand Down Expand Up @@ -1599,6 +1622,7 @@ if(!Array.prototype.random)
p.rotationSpeed = this.minRotationSpeed;
else
p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed;
p.noRotation = this.noRotation;
//set up the lifetime
p.maxLife = lifetime;
//set the blend mode
Expand Down Expand Up @@ -1857,7 +1881,7 @@ if(!Array.prototype.random)
PIXI.particles.Emitter = Emitter;

}(PIXI));


(function(undefined){

// Check for window, fallback to global
Expand Down
4 changes: 2 additions & 2 deletions dist/pixi-particles.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixi-particles",
"version": "1.6.7",
"version": "1.6.8",
"description": "Particle system for PixiJS",
"url": "http://github.com/pixijs/pixi-particles",
"output": "pixi-particles",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixi-particles",
"version": "1.6.7",
"version": "1.6.8",
"main": "dist/pixi-particles.min.js",
"description": "Particle emitter for Pixi.js",
"author": "Andrew Start <[email protected]>",
Expand Down
21 changes: 19 additions & 2 deletions src/Emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,24 @@
* @property {Number} maxStartRotation
*/
this.maxStartRotation = 0;
/**
* If no particle rotation should occur. Starting rotation will still
* affect the direction in which particles move. If the rotation speed
* is set, then this will be ignored.
* @property {Boolean} maxStartRotation
*/
this.noRotation = false;
/**
* The minimum rotation speed for a particle, in degrees per second.
* This only visually spins the particle, it does not change direction of movement.
* This only visually spins the particle, it does not change direction
* of movement.
* @property {Number} minRotationSpeed
*/
this.minRotationSpeed = 0;
/**
* The maximum rotation speed for a particle, in degrees per second.
* This only visually spins the particle, it does not change direction of movement.
* This only visually spins the particle, it does not change direction
* of movement.
* @property {Number} maxRotationSpeed
*/
this.maxRotationSpeed = 0;
Expand Down Expand Up @@ -509,6 +518,13 @@
}
else
this.minStartRotation = this.maxStartRotation = 0;
if (config.noRotation &&
(this.minStartRotation || this.maxStartRotation))
{
this.noRotation = !!config.noRotation;
}
else
this.noRotation = false;
//set up the rotation speed
if (config.rotationSpeed)
{
Expand Down Expand Up @@ -837,6 +853,7 @@
p.rotationSpeed = this.minRotationSpeed;
else
p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed;
p.noRotation = this.noRotation;
//set up the lifetime
p.maxLife = lifetime;
//set the blend mode
Expand Down
13 changes: 10 additions & 3 deletions src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,15 @@
this.velocity.x = this.startSpeed;
this.velocity.y = 0;
ParticleUtils.rotatePoint(this.rotation, this.velocity);
//convert rotation to Radians from Degrees
this.rotation *= ParticleUtils.DEG_TO_RADS;
if (this.noRotation)
{
this.rotation = 0;
}
else
{
//convert rotation to Radians from Degrees
this.rotation *= ParticleUtils.DEG_TO_RADS;
}
//convert rotation speed to Radians from Degrees
this.rotationSpeed *= ParticleUtils.DEG_TO_RADS;
//set alpha to inital alpha
Expand Down Expand Up @@ -382,7 +389,7 @@
{
this.rotation += this.rotationSpeed * delta;
}
else if(this.acceleration)
else if(this.acceleration && !this.noRotation)
{
this.rotation = Math.atan2(this.velocity.y, this.velocity.x);// + Math.PI / 2;
}
Expand Down

0 comments on commit b362817

Please sign in to comment.