Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorBillyT
    • CommentTimeApr 20th 2009
     
    Hiya,

    I've been playing around with this all morning and it seems great, but I'm a little confused - I'm trying to implement a glitter-type effect, and it's getting there, but I can't work out how to Age or restart the process. I've added in the Age below and it just stops everything - what is it I'm missing here...? Also, what's the simplest way to continually generate particles from the original source?

    emitter = new Emitter2D();
    particles = Particle2DUtils.createPixelParticlesFromBitmapData( bmd, emitter.particleFactory, 50, 75);
    emitter.addExistingParticles( particles, false );

    emitter.counter = new Steady( 250 );

    var renderer:PixelRenderer = new PixelRenderer(new Rectangle( 0, 0, 500, 255 ));
    renderer.addEmitter( emitter );
    addChild( renderer );

    emitter.counter = new Steady(250);

    emitter.addInitializer( new Lifetime( 1 ) );
    emitter.addAction(new Age());
    emitter.addAction (new Accelerate( 0, 0));
    emitter.addAction( new RandomDrift( 40, 40 ) );
    emitter.addAction( new Move() );
    emitter.addAction(new Fade());


    emitter.start();

    Thanks for your help, and sorry for being stupid!

    Billy
    • CommentAuthorRichard
    • CommentTimeApr 20th 2009
     
    The lifetime initializer isn't being applied to the particles, because you're adding it after you've added the particles to the emitter. Try this.

    emitter = new Emitter2D();
    emitter.addInitializer( new Lifetime( 1 ) ); // add the initializer
    particles = Particle2DUtils.createPixelParticlesFromBitmapData( bmd, emitter.particleFactory, 50, 75);
    emitter.addExistingParticles( particles, true ); // true causes it to apply the initializer to the particles

    var renderer:PixelRenderer = new PixelRenderer(new Rectangle( 0, 0, 500, 255 ));
    renderer.addEmitter( emitter );
    addChild( renderer );

    emitter.addAction(new Age());
    emitter.addAction( new RandomDrift( 40, 40 ) );
    emitter.addAction( new Move() );
    emitter.addAction(new Fade());

    emitter.start();
    • CommentAuthorBillyT
    • CommentTimeApr 20th 2009
     
    Thank you, that's really useful. Thanks for a great system, and thanks for the quick response!