//导入类
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.energyEasing.Quadratic;
import org.flintparticles.common.events.EmitterEvent;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
//创建2D粒子发射器
var emitter:Emitter2D = new Emitter2D();
//计数器(每一秒中创建5000个粒子)
emitter.counter = new Blast(5000 );
//初始化(粒子的初始位置,速度,图片和颜色)
emitter.addInitializer( new ColorInit( 0xFFFF3300, 0xFFFFFF00 ) );
emitter.addInitializer( new Lifetime( 8 ) );
emitter.addInitializer( new Position( new DiscZone( new Point( 0, 0 ), 8 ) ) );
var bitmapData:BitmapData = new Logo( 300, 80);
emitter.addInitializer( new Velocity( new BitmapDataZone( bitmapData, -152, -380 ) ) );
//向发射器中添加动作,让每一帧都更新粒子的位置
emitter.addAction( new Age( Quadratic.easeIn ) );
emitter.addAction( new Fade( 1.0, 0 ) );
emitter.addAction( new Move() );
emitter.addAction( new LinearDrag( 0.5 ) );
emitter.addAction( new Accelerate( 0, 70 ) );
emitter.addEventListener( EmitterEvent.EMITTER_EMPTY, restart, false, 0, true );
//定位粒子在舞台的上方
var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 550, 400 ) );
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.96,0 ] ) );
renderer.addEmitter( emitter );
addChild( renderer );
emitter.x = 250;
emitter.y = 300;
emitter.start( );
function restart( ev:EmitterEvent ):void
{
Emitter2D( ev.target ).start();
}
|