Flint Particle System Forum - 2 Bugs: p.isDead with TimePeriod & First particle always in top left corner (FollowDisplayObject?) 2012-05-26T06:15:26+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher 2 Bugs: p.isDead with TimePeriod & First particle always in top left corner (FollowDisplayObject?) http://flintparticles.org/forum/comments.php?DiscussionID=559&Focus=1904#Comment_1904 2012-04-08T07:43:06+01:00 2012-05-26T06:15:26+01:00 evo http://flintparticles.org/forum/account.php?u=553 Problem 1: Setting p.isDead on a particle created from a TimePeriod counter doesn't work Here's what I'm doing... particle creation: { counter = new TimePeriod(30, ...
Here's what I'm doing...

particle creation:
{
counter = new TimePeriod(30, .5);

addInitializer( new Lifetime( 3, 4 ) );
addInitializer( new Velocity( new DiscSectorZone( new Point( 0, 0 ), 250, 200, degreesToRadians( -230), degreesToRadians( -140) ) ) );
addInitializer( new SharedImage( new Dot( 5, 0xFF0000 ) ) );
addInitializer( new ScaleImageInit( .25, .55 ) );

addAction( new Age( ) );
addAction( new Move( ) );
addAction( new Accelerate( 0, 300 ) );

addAction( new CollisionZone( new RectangleZone( maxPos.x-1000, maxPos.y, maxPos.x + 2000, maxPos.y + 20 ) ) );

addEventListener(ParticleEvent.ZONE_COLLISION, doCollision);
addEventListener(EmitterEvent.COUNTER_COMPLETE, finishCounter);
}

docollision:
{
var p:Particle2D = Particle2D(e.particle);
p.isDead = true;
}

This code works fine for Blast/Steady counters but TimePeriod is causing the particles to simply bounce off of the collision box.

----------------------------------------------------------------------

Problem 2: The first particle of each new emitter is being created at location 0,0

This may be connected to using FollowDisplayObject but I'm not sure. It seems that with every emitter that I'm creating the first particle emitted is placed at coords 0,0 and animates normally.]]>
2 Bugs: p.isDead with TimePeriod & First particle always in top left corner (FollowDisplayObject?) http://flintparticles.org/forum/comments.php?DiscussionID=559&Focus=1920#Comment_1920 2012-04-26T10:17:55+01:00 2012-05-26T06:15:26+01:00 Richard http://flintparticles.org/forum/account.php?u=1 Hi, I tested both your problems and they work fine for me, including the code you supplied. Would you check that you are using the latest version of Flint. Your second problem was a known issue in an ... 2 Bugs: p.isDead with TimePeriod & First particle always in top left corner (FollowDisplayObject?) http://flintparticles.org/forum/comments.php?DiscussionID=559&Focus=1926#Comment_1926 2012-05-08T08:25:36+01:00 2012-05-26T06:15:26+01:00 evo http://flintparticles.org/forum/account.php?u=553 Here's some more information about my second problem (since I am using the latest release and it still occurs) Here's the particle code: if(_follow){ ...
Here's the particle code:


if(_follow){
addActivity( new FollowDisplayObject(displayObject, _renderer, spreadX, spreadY));
}

counter = new Steady(10);

addInitializer( new Lifetime( .25, 1 ) );
addInitializer( new Velocity( new DiscSectorZone( new Point( 0, 0 ), 80, 60, degreesToRadians( 0), degreesToRadians( 359) ) ) );
if(!_follow){
addInitializer( new Position( new DiscZone( _location, 50 ) ) );
}
addInitializer( new SharedImages( [new Particle1(), new Particle2()]) );
addInitializer( new RotateVelocity(degreesToRadians( -200), degreesToRadians(200)));
addAction( new Rotate() );

addAction( new Age( ) );
addAction( new Move( ) );
addAction( new LinearDrag( 0.5 ) );
addAction( new ScaleImage( .5, 1 ) );
addAction( new Fade( 1, 0 ) );
addAction( new RandomDrift( 200, 200 ) );
addAction( new MutualGravity( 100, 200, 50 ) )

Looking at the code now, I believe it may be due to there being no Position set when using FollowDisplayObject. Just did a quick test though and it seems even when Position is set it still makes the first particle appear at 0,0.

I'll also include some slightly modified FollowDisplayObject code below. I made a small change but I don't believe it's causing the problem.


var e:Emitter2D = Emitter2D( emitter );
var p:Point = new Point( 0, 0 );
p = _displayObject.localToGlobal( p );
p = _renderer.globalToLocal( p );

if(_spreadX != 0){
p.x += Math.floor(Math.random()*(_spreadX))-_spreadX/2;
}
if(_spreadY != 0){
p.y += Math.floor(Math.random()*(_spreadY))-_spreadY/2;
}

e.x = p.x;
e.y = p.y;

I added some variables to create a particle spread around the displayObject and also removed the rotational code since it's not necessary for my application.]]>