Skip to content

Commit

Permalink
Added blend mode support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Start committed Sep 15, 2014
1 parent 214eea3 commit cc04f46
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
25 changes: 25 additions & 0 deletions dist/pixi-particles.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@
return simpleEase;
};

/**
* Gets a blend mode, ensuring that it is valid.
* @method getBlendMode
* @param {String} name The name of the blend mode to get.
* @return {int} The blend mode as specified in the PIXI.blendModes enumeration.
* @static
*/
ParticleUtils.getBlendMode = function(name)
{
if(!name) return PIXI.blendModes.NORMAL;
name = name.toUpperCase();
while(name.indexOf(" ") >= 0)
name = name.replace(" ", "_");
return PIXI.blendModes[name] || PIXI.blendModes.NORMAL;
};

cloudkid.ParticleUtils = ParticleUtils;

/**
Expand Down Expand Up @@ -618,6 +634,11 @@
*/
this.maxRotationSpeed = 0;
/**
* The blend mode for all particles, as named by PIXI.blendModes.
* @property {int} particleBlendMode
*/
this.particleBlendMode = 0;
/**
* An easing function for nonlinear interpolation of values. Accepts a single parameter of time
* as a value from 0-1, inclusive. Expected outputs are values from 0-1, inclusive.
* @property {Function} customEase
Expand Down Expand Up @@ -870,6 +891,8 @@
//set up the lifetime
this.minLifetime = config.lifetime.min;
this.maxLifetime = config.lifetime.max;
//get the blend mode
this.particleBlendMode = ParticleUtils.getBlendMode(config.blendMode);
//use the custom ease if provided
if (config.ease)
{
Expand Down Expand Up @@ -1128,6 +1151,8 @@
p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed;
//set up the lifetime
p.maxLife = lifetime;
//set the blend mode
p.blendMode = this.particleBlendMode;
//set the custom ease, if any
p.ease = this.customEase;
//set the extra data, if any
Expand Down
Loading

0 comments on commit cc04f46

Please sign in to comment.