Flint Particle System Forum - use a Sprite object as particle? 2012-05-26T07:06:51+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1801#Comment_1801 2011-12-13T16:49:48+00:00 2011-12-13T16:50:55+00:00 adeetza http://flintparticles.org/forum/account.php?u=579 Hi guys, I'm trying to build a snow-like project but I want to use self-animating Sprites instead of images as particles. There is a Sprite object inside the Library with the linkage identifier of ... I'm trying to build a snow-like project but I want to use self-animating Sprites instead of images as particles.
There is a Sprite object inside the Library with the linkage identifier of Balloon.

package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.geom.Point;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.particles.Particle2D;
import org.flintparticles.twoD.particles.Particle2DUtils;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;

/**
* ...
* @author Eugene
*/
public class snow extends MovieClip
{
private var emitter:Emitter2D;
private var renderer:DisplayObjectRenderer;
private var dzone:RectangleZone;
private var deathZone:DeathZone;

//init effect
public function snow()
{
emitter = new Emitter2D();
emitter.counter = new Steady(30);

var balPart:Particle2D = Particle2DUtils.createParticle2DFromDisplayObject(new Balloon());
emitter.addParticle(balPart);

emitter.addInitializer( new Position( new LineZone( new Point( -5, -5 ), new Point( 720, -5 ) ) ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 30, 120 ) ) ) );
emitter.addInitializer( new ScaleImageInit( 0.5, 4 ) );

dzone = new RectangleZone( -10, -10, 740, 420 );
deathZone = new DeathZone( dzone, true );
emitter.addAction( deathZone );
emitter.addAction(new Move());
emitter.addAction( new RandomDrift( 110, 10 ));

renderer = new DisplayObjectRenderer();
renderer.addEmitter(emitter);
addChild(renderer);

emitter.runAhead(10);

emitter.start();
}

public function removeEffect() //clean up ram from loader
{
emitter.stop();
renderer.removeEmitter(emitter);
emitter.killAllParticles();
emitter = null;
removeChild(renderer);
}
}
}


Any thoughts?

Thanks in advance!]]>
use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1802#Comment_1802 2011-12-14T10:14:37+00:00 2012-05-26T07:06:51+01:00 adeetza http://flintparticles.org/forum/account.php?u=579 Any help please? use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1809#Comment_1809 2011-12-14T20:27:21+00:00 2011-12-14T20:27:57+00:00 Richard http://flintparticles.org/forum/account.php?u=1 You don't say what exactly isn't working, but on a brief look at your code it looks like you're only creating one particle, and adding it before you add all the actions to the emitter. Don't use ... ImageClass initializer, as used in this example, but pass it your custom class as the image initializer

emitter.addInitializer( new ImageClass( Balloon ) );
This initializer will create a new instance of your custom class for each particle.]]>
use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1812#Comment_1812 2011-12-15T10:03:06+00:00 2012-05-26T07:06:51+01:00 adeetza http://flintparticles.org/forum/account.php?u=579 Thanks for your help, Richard! It works perfectly now! I was afraid I'd lost the animation that occurs inside the Balloon objects (which basically extends the Sprite class but also contains several ...
Again, many thanks for pointing me to the right direction, Richard!]]>
use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1813#Comment_1813 2011-12-15T10:06:25+00:00 2012-05-26T07:06:51+01:00 adeetza http://flintparticles.org/forum/account.php?u=579 By the way... how can I format the code blocks here on the forums so that my code can keep the indentation? use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1836#Comment_1836 2011-12-20T09:20:12+00:00 2012-05-26T07:06:51+01:00 Richard http://flintparticles.org/forum/account.php?u=1 To add code blocks as code, place the code inside elements, and tick the "html" box beneath the comments box.