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

    • CommentAuthorgordeaoux
    • CommentTimeJan 9th 2010 edited
     
    I want to make a faux 3-d starfield that moves bottom-to-top using just the 2D properties of flint. What I need to do is have the larger particles (i.e. closer to the 'camera') move faster than the smaller background particles. Here's some code that I know isn't correct, as it scales all the particles, not individuals. I'm guessing I'll have to implement, extend or modify the particle factory class?

    var scaleSpeed:Number = Math.random()*20;

    var emitter:Emitter2D = new Emitter2D();
    emitter.counter = new Steady( 2 );

    emitter.addInitializer( new ImageClass( Dot, 4 ) );
    emitter.addInitializer( new Position( new LineZone( new Point( -5, stage.stageHeight+12 ), new Point( stage.stageWidth+12, stage.stageHeight+5 ) ) ) );
    emitter.addInitializer( new Velocity( new LineZone( new Point( 0, -1 ), new Point( 0, -scaleSpeed) ) ) );
    emitter.addInitializer( new ColorInit( 0xFF000000, 0x33000000 ) );
    emitter.addInitializer( new ScaleImageInit( 0.25, scaleSpeed ) );


    Also, what tags do you use to display quote on this site? (nvm, it's 'code', I was using ['s instead of <'s)

    Thanks!
    • CommentAuthorgordeaoux
    • CommentTimeJan 11th 2010 edited
     
    Realized how to pull this off own my own, hope this helps someone out there:


    import org.flintparticles.common.counters.*;
    import org.flintparticles.common.displayObjects.Dot;
    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.*;

    var scaleSpeed:Number;
    var initGroup:InitializerGroup;
    var initArray:Array = new Array();
    var initChanceArray:Array = new Array();

    var emitter:Emitter2D = new Emitter2D();

    emitter.counter = new Steady( 10 );

    for(var i:Number = 1; i < 50; i++){
    initGroup = new InitializerGroup();
    scaleSpeed = i*.2;
    initGroup.addInitializer( new ImageClass( Dot, 4 ) );
    initGroup.addInitializer( new Position( new LineZone( new Point( -5, stage.stageHeight+30 ), new Point( stage.stageWidth+30, stage.stageHeight+5 ) ) ) );
    initGroup.addInitializer( new Velocity( new LineZone( new Point( 0, -scaleSpeed*7 ), new Point( 0, -scaleSpeed*7.2) ) ) );
    initGroup.addInitializer( new ColorInit( 0xFFFFFFFF, 0xFFFFFFFF ) );
    initGroup.addInitializer( new ScaleImageInit( scaleSpeed*.1, scaleSpeed*.1 ) );
    initArray.push(initGroup);
    initChanceArray.push(1);
    }

    emitter.addAction( new Move() );
    emitter.addAction( new DeathZone( new RectangleZone( -25, -25, stage.stageWidth+40, stage.stageHeight+40 ), true ) );
    emitter.addInitializer( new ChooseInitializer( initArray, initChanceArray ) );
    //emitter.addAction( new RandomDrift( 20, 20 ) );

    var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
    renderer.addEmitter( emitter );
    addChild( renderer );

    emitter.start();
    emitter.runAhead( 40 );

    • CommentAuthorRichard
    • CommentTimeJan 16th 2010
     
    Nice