Flint Particle System Forum - 2 Bugs: p.isDead with TimePeriod & First particle always in top left corner (FollowDisplayObject?) Sat, 26 May 2012 06:18:56 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & 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 http://flintparticles.org/forum/comments.php?DiscussionID=559&Focus=1904#Comment_1904 Sun, 08 Apr 2012 07:43:06 +0100 evo
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 http://flintparticles.org/forum/comments.php?DiscussionID=559&Focus=1920#Comment_1920 Thu, 26 Apr 2012 10:17:55 +0100 Richard 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 http://flintparticles.org/forum/comments.php?DiscussionID=559&Focus=1926#Comment_1926 Tue, 08 May 2012 08:25:36 +0100 evo
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. ]]>