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

    • CommentAuthorAdz
    • CommentTimeJan 20th 2011
     
    So I've been trying to modify the Gravity Well example so that after a certain time, the particles change color but still retain their positions (though they don't have to retain their speed, though that would be nice too if you have any insight on that). I've tried adding a lifetime to the particles and ageing them, and then upon death change their colour and revive them. This, however, results in the particles all jumping off to the side, and I'm not sure why.

    import org.flintparticles.common.counters.*;
    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.*;
    import org.flintparticles.common.actions.Age;
    import org.flintparticles.common.events.ParticleEvent;
    import org.flintparticles.twoD.particles.*;

    var emitter:Emitter2D = new Emitter2D();

    emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, changeColour );

    emitter.counter = new Blast( 500 );

    emitter.addInitializer( new ColorInit( 0xFFFF00FF, 0xFF00FFFF ) );
    emitter.addInitializer( new Position( new DiscZone( new Point( 200, 200 ), 200 ) ) );
    emitter.addInitializer( new Lifetime ( 10,10 ) );

    emitter.addAction( new Move() );
    emitter.addAction( new Age() );
    emitter.addAction( new GravityWell( 25, 200, 200 ) );
    emitter.addAction( new GravityWell( 25, 75, 75 ) );
    emitter.addAction( new GravityWell( 25, 325, 325 ) );
    emitter.addAction( new GravityWell( 25, 75, 325 ) );
    emitter.addAction( new GravityWell( 25, 325, 75 ) );

    var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 400, 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.99,0 ] ) );
    renderer.addEmitter( emitter );
    addChild( renderer );

    function changeColour(event:ParticleEvent):void
    {

    event.particle.color = 0xFF0000CC;
    event.particle.revive();
    emitter.addExistingParticles( [ event.particle ], true);

    }


    emitter.start();



    I thought that lifetime might be the cause of this problem, so i removed lifetime/age and ran a separate timer that kills the particles every 15 seconds, (which triggers the changeColour function) but they just disappear.

    Any help would be great :) Thanks
    • CommentAuthorAdz
    • CommentTimeJan 20th 2011
     
    Also - I tried changing:

    emitter.addExistingParticles( [ event.particle ], true);

    to:

    emitter.addExistingParticles( [ event.particle ], false);

    this results in the particles reviving in the same position, but as they don't have any of the initializers, I think they just just die over and over again instantly. Though I might be able to make that work with some fiddling....hopefully there is an easier way?
    • CommentAuthorAdz
    • CommentTimeJan 26th 2011
     
    Solved, I just realised that when the particles revive, Point zone is applied again, but is offset from the particles' current position, rather than an absolute position