Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorven
- CommentTimeDec 14th 2010
Hi,
I'm working on a puzzle game, where each of the tiles is a movieclip. When matching tiles get removed an explosion (via Flint) is created. The problem I am having is that after the first explosion, all mouse events are going to Flint even though I have deleted the explosion object. Can someone offer some help/suggestions.
Here is how init the explosion object.
explosions = new Flint( stage.width, stage.height );
addChild( explosions );
Later on when i need to create the explosions, I do:
explosions.addEmitter( x, y, c, c );
When I am done with the explosions I call the following routine:
explosions.removeEmitter();
removeChild( explosions );
explosions = null;
Here is the my Flint class ( I modified one of the examples from the website).
package
{
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.events.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.particles.*;
public class Flint extends Sprite
{
var emitters:Array;
var renderer:BitmapRenderer;
public function Flint( x:int, y:int )
{
emitters = new Array();
renderer = new BitmapRenderer( new Rectangle( 0, 0, x, y ) );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.95,0 ] ) );
addChild( renderer );
}
function addEmitter( x:int, y:int, colorMin:int, colorMax:int )
{
var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Blast( 50 ); // steady, blast
emitter.addInitializer( new SharedImage( new Line( 1 ) ) );
emitter.addInitializer( new ColorInit( colorMin, colorMax ) );
emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 100, 100 ) ) );
emitter.addInitializer( new Lifetime( 0.2, 0.4 ) );
emitter.addAction( new Age() );
emitter.addAction( new Move() );
emitter.addAction( new RotateToDirection() );
emitter.x = x;
emitter.y = y;
emitters.push ( emitter );
renderer.addEmitter( emitter );
emitter.start()
}
function removeEmitter()
{
//http://flintparticles.org/forum/comments.php?DiscussionID=203&page;=1#Item_0
for ( var i:int = 0; i < emitters.length; i++ )
{
// Stop the emitter
emitters[i].stop();
// Clear all the cached particles
ParticleCreator2D( emitters[i].particleFactory ).clearAllParticles();
// Remove references to the emitter
renderer.removeEmitter( emitters[i]);
emitters[i] = null;
}
// Remove references to the renderer
removeChild( renderer );
renderer = null;
}
}
} -
- CommentAuthorven
- CommentTimeDec 14th 2010
Never mind, I found the problem. It seems that I was creating multiple instances of explosions, hence I was only removing once instance of explosion instead of the many that I was unknowingly creating.
-ven
1 to 2 of 2
