Flint Particle System Forum - use a Sprite object as particle? Sat, 26 May 2012 07:10:55 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1801#Comment_1801 http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1801#Comment_1801 Tue, 13 Dec 2011 16:49:48 +0000 adeetza 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 http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1802#Comment_1802 Wed, 14 Dec 2011 10:14:37 +0000 adeetza use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1809#Comment_1809 http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1809#Comment_1809 Wed, 14 Dec 2011 20:27:21 +0000 Richard 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 http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1812#Comment_1812 Thu, 15 Dec 2011 10:03:06 +0000 adeetza
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 http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1813#Comment_1813 Thu, 15 Dec 2011 10:06:25 +0000 adeetza use a Sprite object as particle? http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1836#Comment_1836 http://flintparticles.org/forum/comments.php?DiscussionID=543&Focus=1836#Comment_1836 Tue, 20 Dec 2011 09:20:12 +0000 Richard