Flint Particle System Forum - BlendMode Initializer 2010-11-24T09:55:19+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher BlendMode Initializer http://flintparticles.org/forum/comments.php?DiscussionID=244&Focus=873#Comment_873 2009-07-25T23:27:53+01:00 2009-07-25T23:30:56+01:00 gspschmid http://flintparticles.org/forum/account.php?u=228 Hey there! I only just started using the particle system and it seems pretty well designed. However, there didn't appear to be any way to set a different blendmode for individual emitters in the ... I only just started using the particle system and it seems pretty well designed. However, there didn't appear to be any way to set a different blendmode for individual emitters in the current version. As this seems relatively basic and in my opinion essential to various beautiful effects, I set out to supplement the library with an adequate class (Moreover, apparently there have been other people looking for something like that, as in another thread). Obviously no big effort there, as its basically a one-line change from several other Initializers, nonetheless, for your convenience (and perhaps as an addition to a future version):


package org.flintparticles.twoD.initializers
{
import flash.display.Bitmap;
import flash.display.DisplayObject;
import flash.display.BlendMode;

import org.flintparticles.common.emitters.Emitter;
import org.flintparticles.common.initializers.InitializerBase;
import org.flintparticles.common.particles.Particle;
//import org.flintparticles.twoD.particles.Particle2D;

/**
* The BlendMode Initializer sets the blendmode of the particle.
*/

public class BlendModeInit extends InitializerBase
{
private var _blendmode : String;

/**
* The constructor creates a BlendMode initializer for use by
* an emitter. To add a BlendMode to all particles created by an emitter, use the
* emitter's addInitializer method.
* The particle in question must be rendered using a DisplayObject (which includes
* Bitmaps), since Flash only supports blendmodes for that class.
*
* @param blendmode The blendmode to apply to the particles.
*/
public function BlendModeInit( blendmode : String )
{
_blendmode = blendmode;
}

/**
* The blendmode.
*/
public function get blendmode():String
{
return _blendmode;
}
public function set blendmode( blendmode : String ):void
{
_blendmode = blendmode;
}

/**
* @inheritDoc
*/
override public function initialize( emitter : Emitter, particle : Particle ) : void
{
//var p:Particle2D = Particle2D( particle );
if (particle && particle.image is DisplayObject) {
(particle.image as DisplayObject).blendMode = _blendmode;
}
}
}
}
]]>