Flint Particle System Forum - removeParticle causing null reference error 2012-05-27T07:00:11+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher removeParticle causing null reference error http://flintparticles.org/forum/comments.php?DiscussionID=493&Focus=1657#Comment_1657 2011-06-29T10:09:24+01:00 2012-05-27T07:00:11+01:00 mafsays http://flintparticles.org/forum/account.php?u=513 so i have an emitter and I'm adding a CollisionZone, and listening for ZONE_COLLISION events - I want to remove the particles when they hit the collision zone: var rect : Rectangle = new ...
var rect : Rectangle = new Rectangle( 100, 300, 400, 30 );
emitter.addAction( new CollisionZone( new RectangleZone( rect.x, rect.y, rect.x + rect.width, rect.y + rect.height ) ) );
emitter.addEventListener( ParticleEvent.ZONE_COLLISION, onZoneCollision );

protected function onZoneCollision( e : ParticleEvent ) : void
{
var particle : Particle2D = Particle2D( e.particle );
emitter.removeParticle( particle );
}

this all works, but the update loop continues to try and reference the particle i've removed and i therefore get a null reference error - at what point is it safe to remove a particle to avoid this, or what's the best way to approach removing a particle based on an event dispatched during the update loop?]]>
removeParticle causing null reference error http://flintparticles.org/forum/comments.php?DiscussionID=493&Focus=1658#Comment_1658 2011-06-29T10:54:18+01:00 2012-05-27T07:00:11+01:00 mafsays http://flintparticles.org/forum/account.php?u=513 have gone for: protected function onZoneCollision( e : ParticleEvent ) : void { var particle : Particle2D = Particle2D( e.particle ); particle.isDead = true; } this then lets the emitter ...
protected function onZoneCollision( e : ParticleEvent ) : void
{
var particle : Particle2D = Particle2D( e.particle );
particle.isDead = true;
}

this then lets the emitter take care of clearing up the particle. Still be interested to hear when, if ever, removeParticle() is a valid call to make - it doesn't seem to remove the particle as effectively as the code in update()]]>
removeParticle causing null reference error http://flintparticles.org/forum/comments.php?DiscussionID=493&Focus=1681#Comment_1681 2011-07-31T16:59:15+01:00 2012-05-27T07:00:11+01:00 Richard http://flintparticles.org/forum/account.php?u=1 The conceptual difference between removing a particle (emitter.removeParticle(particle)) and killing the particle (particle.isDead=true) is, in the former case the assumption is that you don't want ...
As you point out, removeParticle doesn't work correctly during the update cycle. I've just now fixed this, and checked the fix into the github repository.

Which you should be using depends on whether you actually want to kill the particle or just remove it from the emitter and place it elsewhere.]]>
removeParticle causing null reference error http://flintparticles.org/forum/comments.php?DiscussionID=493&Focus=1686#Comment_1686 2011-08-01T12:34:44+01:00 2012-05-27T07:00:11+01:00 SimoensS http://flintparticles.org/forum/account.php?u=524 Is this new version the same one as on the download page ? I'm having the same problem and after redownloading the source code it still throws the null pointer exception error. I want particles ...
I want particles that have collided with a collision zone to stay where they are, so I removed them from the emitter expecting them to stay without being updated.
Is there another better way to stop certain particles from being updated, for example an ignore property ?]]>
removeParticle causing null reference error http://flintparticles.org/forum/comments.php?DiscussionID=493&Focus=1688#Comment_1688 2011-08-06T11:18:51+01:00 2011-08-06T11:19:26+01:00 Richard http://flintparticles.org/forum/account.php?u=1 No, it isn't in a formal release yet. Until it is, the only way to get the revised code it is to use git to checkout the github repository.