Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
Bug reports: 2 Bugs: p.isDead with TimePeriod & First particle always in top left corner (FollowDisplayObject?)
Bottom of Page1 to 4 of 4
-
- CommentAuthorevo
- CommentTimeApr 8th 2012
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, .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. -
- CommentAuthorRichard
- CommentTimeApr 26th 2012
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 earlier version but is fixed now. -
- CommentAuthorevo
- CommentTimeMay 8th 2012
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){
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. -
- CommentAuthorevo
- CommentTimeJun 7th 2012
So I think I've narrowed down the problem a bit... it appears that some of the particles being created aren't having the FollowDisplayObject activity applied to them. I first checked this by adding traces within FollowDisplayObject and noticing that even though particles were appearing at origin, their positions were not being traced in the activity.
I then added traces to Move.as and saw that the first particle or 2 created were sometimes placed within a few pixels of 0,0. The problem seemed to be exacerbated when creating more and more Emitters (is there some sort of built in performance handler that would skip "Move" actions?). For example, when creating 1 Emitter at a time, occasionally a particle would start at origin, and it was always the first one or two and it would always be within 2 pixels of 0,0. When creating 5-10 Emitters in rapid succession the likelihood of particles starting at origin increased, and they were usually offset within 5-10 pixels of 0,0.
By the way, this is all using the latest Flint and the particle settings above. What could be causing the system to ignore FollowDisplayObject activities for the first particles? Please help me figure this out, I owe you a donation which I'll do just as soon as this problem is solved :)
1 to 4 of 4
