Flint Particle System Forum - How can I assign different sprites to particles? 2011-12-13T06:49:47+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher How can I assign different sprites to particles? http://flintparticles.org/forum/comments.php?DiscussionID=349&Focus=1188#Comment_1188 2010-04-21T20:12:41+01:00 2011-12-13T06:49:47+00:00 timdiacon http://flintparticles.org/forum/account.php?u=357 I am trying to create a pool of particles where each particle is a different icon, I also need to add icons to this pool. Currently I have a display object renderer with an emitter. I then have a ...
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 2010-05-12T19:17:26+01:00 2010-05-12T19:35:27+01:00 birdsigh http://flintparticles.org/forum/account.php?u=366 A better way to do this would be to use the 'createParticles2DFromDisplayObjects' function. This will return an array of particles, created from an Array of DisplayObjects you pass it. Adding this ...
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 2010-05-19T07:57:20+01:00 2011-12-13T06:49:47+00:00 Richard http://flintparticles.org/forum/account.php?u=1 One possible problems is that a single display object can only be in one place at any time. If you use the same icon in two particles, it will be removed from the first particle's display list when ...