Flint Particle System Forum - Make particles of two emitters to collide, or change emitter counter properties in real time Sun, 13 Jun 2010 02:07:23 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.4 & Feed Publisher Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=536#Comment_536 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=536#Comment_536 Fri, 21 Nov 2008 15:14:38 +0000 ifthenelse 1. make the emitter shoot a blast of 1000 particles at the application start;
2. and then shot 10 particles every second which will collide with the first 1000 (using the same emitter initializers).

The emitter has a DiscZone position initializer. The particles are accellerated by a GravityWell at the center of the stage with a ZonedAction and then dragged to reach stillness in a circular area at the center.

Hope that these two sketches can help to understand (sorry for the poor quality, but I had no plain support to draw):



I've tried to use two emmiters (the first is a Blast and the second is a Steady) and associate them to an unique renderer, but their respective particles don't collide.
Then, I've tried to use a Pulse emitter and assigning its quantity and period to two variables, regulated by the getTimer() function (which gives the milliseconds since the application started), but I can't make them change value. Moreover getTimer() is affected by growing latency.

Is there a way to make the particles generated by two different emitters to collide? Or to make the emitter counter properties change in real-time? Also, suggestions for alternative ways are welcome. Thanks! ]]>
Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=537#Comment_537 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=537#Comment_537 Fri, 21 Nov 2008 15:24:01 +0000 psilos Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=538#Comment_538 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=538#Comment_538 Fri, 21 Nov 2008 15:39:21 +0000 ifthenelse emitter.runAhead(100); but in this way the intial circle is already built. Instead, I would like to, for first, make it with a blast of 1000 particles emitted in the same moment, and then, emit 10 particles per second which will collide with those that were shot previously. ]]> Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=539#Comment_539 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=539#Comment_539 Fri, 21 Nov 2008 15:46:06 +0000 psilos Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=547#Comment_547 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=547#Comment_547 Sun, 23 Nov 2008 07:18:46 +0000 alphagod
emitter.counter = new PerformanceAdjusted(4, 100, 33);
//initialize properties
emitter.start();

and then

emitter.counter = new Steady(500);
emitter.start();

Works as it should and changes whenever it needs to. ]]>
Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=548#Comment_548 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=548#Comment_548 Sun, 23 Nov 2008 16:47:54 +0000 ifthenelse Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=549#Comment_549 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=549#Comment_549 Sun, 23 Nov 2008 17:39:23 +0000 Richard
emitter.counter = new Blast( 1000 );
//initialize properties
emitter.start();


and then

emitter.counter = new Steady( 10 ); ]]>
Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=556#Comment_556 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=556#Comment_556 Tue, 25 Nov 2008 00:43:33 +0000 ifthenelse TurtleSVN, but I don't know how to check their version and to make an extension package for Flash. Anyway I have been in a hurry, so I used the 2.0.0. Please, forgive me, but I'm a true noob. So, by the moment, I used the method suggested by alphagod.
Everything works good, but, there's something that doesn't add up: the two counters are associated to two seprate initializerGroup (blastGroup and pAGroup) and, since they're actually equal (except for different Lifetime values), the respective particles are supposed to be generated in the same area (precisely on a ring outside the stage). Instead, those of the PerformanceAdjusted emitter are generated in a random position both in and out of bounds.
I checked the code and run it at least 50 times, also changing the second counter with a Steady, but the result doesn't change. I really don't understand where the problem is. Perhaps can you glance at it? Heres the code, if anybody that wants to make a test. It is not the whole job... this just contains the data about particles.


/*Importing libraries*/
import flash.utils.getTimer;
import flash.display.StageScaleMode;
import flash.geom.Point;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.energyEasing.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.Dot;
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.renderers.*;
import org.flintparticles.twoD.zones.*;

/*Tells how to build emitter counter according to the time passed*/
function timeCount(event:TimerEvent):void
{
var timeStore:uint;
timeStore = getTimer();
//trace( "timeCount() called @ " + timeStore + " ms" );
if( timeStore < 2000 )
{
emitter.counter = new Blast( 1000 );
emitter.addInitializer( new ChooseInitializer( [ blastGroup ] ) );
emitter.start();

}
else
{
if( timeStore > 26000 )
{
myTimer.stop();
myTimer.removeEventListener( TimerEvent.TIMER, timeCount );
emitter.counter = new PerformanceAdjusted( 8, 11, 60 );
emitter.addInitializer( new ChooseInitializer( [ pAGroup ] ) );
emitter.start();

}

}

}

/*Stage Resizer to keep aspect ratio*/
stage.scaleMode = StageScaleMode.SHOW_ALL;

/*Declaring emitters*/
var particleRadius:Number = 7;
var emitter:Emitter2D = new Emitter2D();

/*Declaring colors*/
var color1:uint = 0xFFFF1234;
var color2:uint = 0xFF12FF34;
var color3:uint = 0xFF1234FF;

/*Building colors array*/
var colorsArray:Array = [ color1, color2, color3 ];

/*Declaring geometric variables*/
var hCenter:Number = stage.stageWidth * 0.5;
var vCenter:Number = stage.stageHeight * 0.5;
var startRadiusMax:Number = ( stage.stageWidth * 0.5 * 1.8 );
var startRadiusMin:Number = ( stage.stageWidth * 0.5 * 1.1 );

/*Setting timer variable and its delay*/
var myTimer:Timer = new Timer(1000);
myTimer.start();

/*Initializers group for the Blast counter*/
var blastGroup:InitializerGroup = new InitializerGroup();
blastGroup.addInitializer( new ImageClass( Dot, particleRadius ) );
blastGroup.addInitializer( new ColorsInit( colorsArray ) );
blastGroup.addInitializer( new Lifetime( 150, 600 ) );
blastGroup.addInitializer( new MassInit( particleRadius ) );
blastGroup.addInitializer( new CollisionRadiusInit( particleRadius ) );
blastGroup.addInitializer( new Position( new DiscZone( new Point( hCenter, vCenter ), startRadiusMax, startRadiusMin ) ) );

/*Initializers group for the PerformanceAdjusted counter*/
var pAGroup:InitializerGroup = new InitializerGroup();
pAGroup.addInitializer( new ImageClass( Dot, particleRadius ) );
pAGroup.addInitializer( new ColorsInit( colorsArray ) );
pAGroup.addInitializer( new Lifetime( 480, 660 ) );
pAGroup.addInitializer( new MassInit( particleRadius ) );
pAGroup.addInitializer( new CollisionRadiusInit( particleRadius ) );
pAGroup.addInitializer( new Position( new DiscZone( new Point( hCenter, vCenter ), startRadiusMax, startRadiusMin ) ) );

/*Defining emitter actions*/
emitter.addAction( new Move() );
emitter.addAction( new Age() );
emitter.addAction( new Collide( 0.1 ) );
emitter.addAction( new ZonedAction( new GravityWell( 900, hCenter, vCenter, startRadiusMax+100 ), new DiscZone( new Point( hCenter, vCenter ), startRadiusMax+100, stage.stageWidth * 0.15 ) ) );
emitter.addAction( new LinearDrag( 0.88 ) );

/*Render initializations*/
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
addChild( renderer );
renderer.addEmitter( emitter );

/*Time Event Listener*/
myTimer.addEventListener(TimerEvent.TIMER, timeCount);
]]>
Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=557#Comment_557 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=557#Comment_557 Tue, 25 Nov 2008 07:30:36 +0000 alphagod
var lifeTime:Lifetime = new Lifetime( 480, 660 );
addInitializer( lifeTime );

this way you can remove an initializer later with removeInitializer(lifeTime); this way you also would have less intializer objects at the end as you just change the already created ones values not create whole new ones and add them to the emitter. I can't check your code because I'm not on a machine with flash on but this may be the reason for the different results.

As for using the svn it's very simple, just move the entire org folder somewhere within your class path and you can access it just like before. ]]>
Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=563#Comment_563 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=563#Comment_563 Mon, 01 Dec 2008 03:41:54 +0000 ifthenelse Make particles of two emitters to collide, or change emitter counter properties in real time http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=564#Comment_564 http://flintparticles.org/forum/comments.php?DiscussionID=137&Focus=564#Comment_564 Mon, 01 Dec 2008 08:14:50 +0000 Richard