Flint Particle System Forum - How can I assign different sprites to particles? Tue, 13 Dec 2011 07:16:49 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher How can I assign different sprites to particles? http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1188#Comment_1188 http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1188#Comment_1188 Wed, 21 Apr 2010 20:12:41 +0100 timdiacon
When I need to add an icon to the swarm I add an ImageClass as an initializer, grab a particle from the particle factory and then use addExstingParticles.

emitter.addInitializer(new ImageClass(IconParticle, icon));
var p:Particle = emitter.particleFactory.createParticle();
emitter.addExistingParticles([p], false);

This works great for the first particle but when I try and add a second particle containing a different icon the first one stops moving and is the "rubbed out" as the new one passes over the top of it.

Is it possible to achieve what I am attempting and if so am I going about it completely wrong (I suspect so!)

Any help appreciated :) ]]>
How can I assign different sprites to particles? http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1199#Comment_1199 http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1199#Comment_1199 Wed, 12 May 2010 19:17:26 +0100 birdsigh
private function addSpriteToParticleSystem(img:DisplayObject):void {
var particles:Array = Particle2DUtils.createParticles2DFromDisplayObjects([img], renderer);
emitter.addExistingParticles(particles, true);
}

Be careful that if you leave the second param in addExistingParticles set to true then all initialisers will be applied to the new particle added. So if you have an initial appearance set in the initialisers then this function will simply create a new particle, rather than add your custom Sprite particle!

Hope this helps!

edit:
Just noticed, there is also the 'createParticle2DFromDisplayObject', which returns an individual Particle2D from a DisplayObject. This may be better suited for what you need. ]]>
How can I assign different sprites to particles? http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1212#Comment_1212 http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1212#Comment_1212 Wed, 19 May 2010 07:57:20 +0100 Richard