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

    • CommentAuthorDrny
    • CommentTimeNov 3rd 2011
     
    Hi, i would like to have a little particle background, where white dots (stars) appear on the edges of stage, fly to the center while getting smaller, and disappear. I watched the examples and i do not get if i can do it in 2d or is it not enough and 3d is needed. Maybe somebody have done such an effect, im quite new to as3, and all of it. Managing such huge packages is quite hard at the moment. Could anyone help:)
    • CommentAuthorDrny
    • CommentTimeNov 4th 2011
     
    Ok, this is how far i got. i used the snow example, as i thought that if the stars is all different size, they do not get to get smaller so much, this would do. So i changed the position inn to multizone, and did four linezones on the edges of the stage. now, i do not know how to make them all go to the center , coz Velocity, altough it has a pointzone, and i though that should make them go to the point, but they dont. I tryed to do the tween to zone, but didnt work either. here is what i got ( although its almost the same as snoweffect) :

    in the Main :

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

    emitter.start();
    emitter.runAhead( 10 );


    and the stars class :


    package
    {
    import flash.geom.Point;
    import org.flintparticles.common.counters.*;
    import org.flintparticles.common.displayObjects.RadialDot;
    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.zones.*;
    import flash.display.Stage;

    public class Stars extends Emitter2D
    {
    public function Stars()
    {
    counter = new Steady(20);

    addInitializer( new ImageClass( RadialDot, [2] ) );
    var mZone:MultiZone = new MultiZone()
    mZone.addZone( new LineZone(new Point(-5,-5),new Point( 535, -5)));
    mZone.addZone( new LineZone(new Point(-5,-5),new Point(-5,605)));
    mZone.addZone( new LineZone(new Point(-5,605),new Point(535,605)));
    mZone.addZone( new LineZone(new Point(535,605),new Point(535,-5)));

    addInitializer( new Position(mZone ));
    addInitializer( new Velocity( new PointZone( new Point(50, 50 ) ) ) );
    addInitializer( new ScaleImageInit( 0.75, 2 ) );

    addAction( new Move() );
    //addAction( new TweenToZone( new LineZone(new Point( 200, 200),new Point(220,220))));
    addAction( new DeathZone( new RectangleZone( 200,200,200,200 ), false ) );
    //addAction( new RandomDrift( 15, 15 ) );
    }
    }
    }



    could anyone lead me how to get the particles go to the center?

    thanks.
    • CommentAuthorDrny
    • CommentTimeNov 4th 2011
     
    ok, so this is what if done :


    package
    {
    import flash.geom.Point;
    import org.flintparticles.common.counters.*;
    import org.flintparticles.common.displayObjects.RadialDot;
    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.zones.*;
    import flash.display.Stage;

    public class Stars extends Emitter2D
    {
    public function Stars()
    {
    var center:int = (Field.instance.FW*Field.instance.TS-Field.instance.TS>>1)
    counter = new Steady(10);

    addInitializer( new ImageClass( RadialDot, [2] ) );
    addInitializer( new ColorInit( 0xFFF3FF05, 0xFFFFFFFF ) );

    var mZone:MultiZone = new MultiZone();
    mZone.addZone( new LineZone(new Point(-5,-5),new Point( 535, -5)));
    mZone.addZone( new LineZone(new Point(-5,-5),new Point(-5,605)));
    mZone.addZone( new LineZone(new Point(-5,605),new Point(535,605)));
    mZone.addZone( new LineZone(new Point(535,605),new Point(535,-5)));

    addInitializer( new Position(mZone ));
    addInitializer( new ScaleImageInit( 0.75, 2 ) );

    addAction( new Move() );
    addAction( new GravityWell(50,264,268,88));
    addAction( new MutualGravity(10,10,10 ));
    addAction( new DeathZone( new DiscZone(new Point(center,center),17,0), false ) );

    }
    }
    }


    Now i can see all of the beauty of this particle sistem. And i wanted to do more! I donk know if i should create a new topic to spam more than i have done, so i will ask here for now ( you wont get rid of me!).
    i wanted to do the tweenTo a sprite. So i saw in the example that i need a bitmap data, so i converted the bitmap for sprite, but now i get this error :

    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::BitmapData@29bd9131 to org.flintparticles.twoD.zones.BitmapDataZone. WHY?

    i read in documentation that BitmapDataZone needs BitmapData, so what is wrong? here is what if done. :



    package
    {
    import flash.geom.Point;
    import org.flintparticles.common.counters.*;
    import org.flintparticles.common.displayObjects.RadialDot;
    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.zones.*;
    import flash.display.Stage;
    import flash.display.BitmapData;
    import org.flintparticles.twoD.renderers.BitmapRenderer;
    import org.flintparticles.twoD.renderers.BitmapLineRenderer;
    import flash.display.Bitmap;

    public class tetroCreation extends Emitter2D
    {
    var center:int = Field.instance.TS;
    public function tetroCreation(y1:int,x1:int,tetro)
    {
    var bitData:BitmapData = new BitmapData(tetro.width,tetro.height,false);
    bitData.draw(tetro);
    var mZone:MultiZone = new MultiZone();
    mZone.addZone( new LineZone(new Point(-5,-5),new Point( 535, -5)));
    mZone.addZone( new LineZone(new Point(-5,-5),new Point(-5,605)));
    mZone.addZone( new LineZone(new Point(-5,605),new Point(535,605)));
    mZone.addZone( new LineZone(new Point(535,605),new Point(535,-5)));

    counter = new Blast(40);

    addInitializer( new ImageClass( RadialDot, [2] ) );
    addInitializer( new ColorInit( 0xFFF3FF05, 0xFFFFFFFF ) );
    trace( x1*center,y1*center);
    addInitializer( new Position( new DiscZone( new Point( x1*center,y1*center), 28 ) ) );
    addInitializer( new ScaleImageInit( 0.75, 2 ) );


    addAction( new TweenToZone(BitmapDataZone( bitData )))

    //addAction(new DeathZone(mZone,false));

    //addAction( new Move() );
    //addAction( new GravityWell(50,264,268,88));
    //addAction( new MutualGravity(10,10,10 ));
    //addAction( new DeathZone( new DiscZone(new Point(center,center),4,0), true ) );
    //addAction( new RandomDrift( 15, 15 ) );



    }
    }
    }


    this is the sprite ( i tried : sending as bitmap, sending as sprite, converting to even Bitmap, BitmapData, leaving a sprite...) :


    public function drawTetromino():void
    {
    var ct:uint = currentTetromino;
    tetromino=new Sprite();
    addChild(tetromino);
    tetromino.graphics.lineStyle(0,0x000000);
    var glow:GlowFilter = new GlowFilter(0xFFFF00,0.4,6,6,2,2);
    tetromino.filters = new Array(glow);
    for (var i:int=0; i<tetrominoes[ct][currentRotation].length; i++)
    {
    for (var j:int=0; j<tetrominoes[ct][currentRotation][i].length; j++)
    {
    if (tetrominoes[ct][currentRotation][i][j] == 1)
    {

    tetromino.graphics.beginFill(colors[ct]);
    tetromino.graphics.drawRect(Field.instance.TS*j,Field.instance.TS*i,Field.instance.TS,Field.instance.TS);
    tetromino.graphics.endFill();


    }
    }
    }
    tetromino.cacheAsBitmap = true;
    var bitTetro:BitmapData = new BitmapData(tetromino.width,tetromino.height,false,colors[ct]);
    bitTetro.draw(tetromino);
    var tEmiter:tetroCreation = new tetroCreation((tRow+i),(tCol+j),tetromino);
    var rend:DisplayObjectRenderer = new DisplayObjectRenderer();
    Main.instance.renderer.addEmitter(tEmiter);
    tEmiter.start();
    addChild(rend);
    placeTetromino(tRow,tCol);
    }


    again. i need help. as you can see im trying my best, while writing here, i would appreciate any help, and it helps to realize my problems better when i write here, i think..
    • CommentAuthorRichard
    • CommentTimeNov 5th 2011 edited
     
    You missed out the word "new" to initialize the BitmapDataZone. This code -

    addAction( new TweenToZone(BitmapDataZone( bitData )))

    Tries to cast the BitmapData to a BitmapDataZone. You instead need

    addAction( new TweenToZone( new BitmapDataZone( bitData )))