Flint Particle System Forum - Features Sun, 11 Dec 2011 10:52:29 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1509#Comment_1509 http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1509#Comment_1509 Fri, 14 Jan 2011 14:53:26 +0000 FlashDev2007
1. Can I create particles from any display object I create, eg. some bubbles that open up with text in when I click them?
2. Is it possible to make certain particles get attracted to one I click on?
3. Can you change the movement behaviour at runtime?

Many thanks,

Neil ]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1510#Comment_1510 http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1510#Comment_1510 Sun, 16 Jan 2011 18:17:22 +0000 FlashDev2007
Any ideas?


package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;

import org.flintparticles.common.counters.Blast;
import org.flintparticles.common.displayObjects.Star;
import org.flintparticles.common.initializers.CollisionRadiusInit;
import org.flintparticles.common.initializers.ImageClass;
import org.flintparticles.common.initializers.MassInit;
import org.flintparticles.twoD.actions.BoundingBox;
import org.flintparticles.twoD.actions.Collide;
import org.flintparticles.twoD.actions.Move;
import org.flintparticles.twoD.actions.Rotate;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.Position;
import org.flintparticles.twoD.initializers.RotateVelocity;
import org.flintparticles.twoD.initializers.Velocity;
import org.flintparticles.twoD.renderers.DisplayObjectRenderer;
import org.flintparticles.twoD.zones.DiscZone;
import org.flintparticles.twoD.zones.RectangleZone;

[SWF (backgroundColor="#000000")]
public class FlintTest extends Sprite
{
protected static const PARTICLE_COUNT:int = 25;
protected var emitter:Emitter2D;

public function FlintTest()
{
emitter = new Emitter2D();
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
renderer.mouseChildren = true;
renderer.mouseEnabled = true;
renderer.addEventListener(MouseEvent.CLICK, clickHandler);
renderer.addEmitter(emitter);
addChild(renderer);

emitter.counter = new Blast(PARTICLE_COUNT);
emitter.addInitializer(new Position(new RectangleZone(0,0,stage.stageWidth, stage.stageHeight)));
emitter.addInitializer(new ImageClass(MyParticle));

var zone:DiscZone = new DiscZone(new Point(0, -50), 100, 10);
emitter.addInitializer(new Velocity(zone));
emitter.addInitializer(new CollisionRadiusInit(20));
emitter.addInitializer(new MassInit(Math.random()*0.1));
emitter.addInitializer( new RotateVelocity(-Math.PI / 2, Math.PI / 2));

emitter.addAction(new Move());
emitter.addAction(new BoundingBox(0,0,stage.stageWidth, stage.stageHeight));
emitter.addAction(new Collide());
emitter.addAction(new Rotate());
emitter.start();

for(var i:int = 0; i < renderer.numChildren; i++)
{
var particle:Sprite = Sprite(renderer.getChildAt(i));
particle.useHandCursor = true;
particle.buttonMode = true;
particle.addEventListener(MouseEvent.CLICK, clickHandler);
}
}

protected function clickHandler(event:MouseEvent):void
{
trace("clicked: " + event.target.name)
}
}
}
]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1515#Comment_1515 http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1515#Comment_1515 Tue, 18 Jan 2011 03:25:01 +0000 Richard
You can modify behaviour at runtime by either

1. adding and removing actions from/to the emitter to change the behaviour.
2. using an action that alters its behaviour dynamically (writing your own actions is not hard - look in the source code of a few of the included actions for clues).

Richard ]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1517#Comment_1517 http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1517#Comment_1517 Tue, 18 Jan 2011 14:32:04 +0000 FlashDev2007
Neil ]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1518#Comment_1518 http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1518#Comment_1518 Tue, 18 Jan 2011 14:43:01 +0000 FlashDev2007
Cheers ]]>