Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorven
- CommentTimeDec 16th 2010
I'm working on a title matching game, and when multiple matches happen I remove the tiles and put a particle explosion in the place of each of the tiles. Without the explosions, my frame rate stays at 60fps, with explosions on, I am getting 45fps. I even tried increasing the stage FPS from 60fps to 120fps, but the frame rate stays in the high 40's. Each explosion (emitter) is initialized as:
var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Blast( 50 );
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() );
I create only one renderer, initialized as:
renderer = new BitmapRenderer( new Rectangle( 0, 0, stageWidth, stageHeight ) );
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 );
In reading an old post it was recommend to keep the rectangle area small when using BitmapRenderer. Currently, my BitmapRenderer is set to the entire stage to cover 3-8 emitters for the single renderer than can be generated.
Is it advisable to keep one emitter per renderer and reduce the area size to cover only that explosion? If so, what would be the best way to removed the renderer after the explosion has completed. Should I attach a listener to renderer and then remove itself. I'm asking before I go rip up a bunch of code.... Thanks.
-ven -
- CommentAuthorRichard
- CommentTimeDec 20th 2010
Listen for the emitterEmpty event to indicate that there are no more particles on the emitter, then stop the emitter, remove it from the renderer and remove the renderer from the stage.emitter.addEventListener( EmitterEvent.EMITTER_EMPTY, cleanUp );
function cleanUp( event:EmitterEvent ):void
{
emitter.stop();
renderer.removeEmitter( emitter );
removeChild( renderer );
renderer = null;
emitter = null;
} -
- CommentAuthorven
- CommentTimeDec 21st 2010
Thanks Richard...will try it out.
1 to 3 of 3
