Flint Particle System Forum - Physically based Particles Thu, 23 Jun 2011 16:38:07 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Physically based Particles http://flintparticles.org/forum/comments.php?DiscussionID=167&Focus=671#Comment_671 http://flintparticles.org/forum/comments.php?DiscussionID=167&Focus=671#Comment_671 Mon, 09 Feb 2009 20:46:01 +0000 BorisTheBrave I've released a library that ties the Box2D Flash physics engine in with Flint. With a few lines of code, you can have Box2D's full power while still using all the Flint primitives you are used to.

More details are here, with a demo available.

If you click twice on the demo, you'll find the "Flint only" example, aimed at Flint users. I append the bulk of the source for that to give you an idea how simple it is to get started.

BodyRenderer.defaultScale = 10;

//Create a Flint emitter and initialize it with some standard particles stuff
emitter = new Emitter2D();
emitter.counter = new Steady( 15 );
emitter.addInitializer(new Position(new DiscZone(new Point(0,0),30,30)));
emitter.addActivity(new FollowMouse(this));
emitter.addAction(new MutualGravity(3, 100));
emitter.addInitializer(new Velocity(new DiscZone(new Point(0, 0), 10, 10)));
emitter.addInitializer(new ImageClass(Dot, 10));
emitter.addInitializer(new Lifetime(2, 20));
emitter.addAction(new Fade());
emitter.addAction(new Age());

//Use a physics activity, and keep a reference to it.
var physics:Physics = new Physics();
emitter.addActivity(physics);
//Lets give the position solver a bit more pep, as we are creating lots of overlapping shapes
physics.positionIterations = 30;

emitter.addInitializer(new CollisionRadiusInit(10));
emitter.addInitializer(new CircleInit(physics.world));

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

emitter.start();


I'm afraid for more complicated effects, you'll actually need to learn something about Box2D, but nonetheless, I think it's a fairly easy system to use. ]]>
Physically based Particles http://flintparticles.org/forum/comments.php?DiscussionID=167&Focus=673#Comment_673 http://flintparticles.org/forum/comments.php?DiscussionID=167&Focus=673#Comment_673 Wed, 11 Feb 2009 07:56:05 +0000 Richard