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

    • CommentAuthorWolv3r
    • CommentTimeMay 14th 2012 edited
     
    Hello,

    I'm working on a game with a plane and I try to use the particle system to generate a contrail of a plane when it boosts up.


    this is my Class:

    package particle {

    import org.flintparticles.twoD.emitters.Emitter2D;
    import org.flintparticles.twoD.actions.*;
    import org.flintparticles.twoD.initializers.*;
    import org.flintparticles.twoD.renderers.*;
    import org.flintparticles.twoD.zones.*;
    import org.flintparticles.common.actions.*;
    import org.flintparticles.common.counters.*;
    import org.flintparticles.common.initializers.*;
    import org.flintparticles.common.displayObjects.*;
    import org.flintparticles.twoD.activities.FollowDisplayObject;
    import flash.geom.Point;
    import flash.display.DisplayObject;

    public class BoostEmitter extends Emitter2D {

    public function BoostEmitter(plane, renderer) {

    this.counter = new ZeroCounter();

    this.addInitializer(new Lifetime(1,1));
    this.addInitializer(new Position(new LineZone(new Point(0, 0), new Point(-200, 0))));
    this.addInitializer(new ImageClass( Line, [10] ));

    this.addAction(new RotateToDirection());
    this.addAction(new Age());
    this.addAction(new Move());
    this.addAction(new Fade(0.8, 0));

    this.addActivity(new FollowDisplayObject(plane, renderer));
    }

    public function startEffect() {
    this.counter = new Steady(24);
    }

    public function stopEffect() {
    this.counter = new ZeroCounter();
    }
    }
    }

    This is my extended emitter class.

    And this my renderer:

    private var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
    private var boostemitter:BoostEmitter;

    private function InitEmitter(plane) {
    this.addChild(renderer);
    boostemitter = new BoostEmitter(plane, renderer);
    renderer.addEmitter(boostemitter);
    boostemitter.start();
    }

    My problem right now:

    The RotateToDirection() doesn't work. When my plane flies upwards in an angle of 40° the created particles will have an angle of 0° but they move in the 40° direction.
    • CommentAuthorWolv3r
    • CommentTimeMay 18th 2012 edited
     
    I tried the "Rotate()" function and it works now. But now I got a new problem: How can I add a filter to the Renderer when it's a DisplayObjectRenderer? I need to get the tail effect on my particles.

    But I can not use the BitmapRenderer cause the Game is like a SideScroller with infinity width and height. Or is there a way to increase width and height of the renderer in realtime?
    • CommentAuthorRichard
    • CommentTimeOct 29th 2012 edited
     
    You can resize the BitmapRenderer by setting its canvas property. However, currently this simply throws away the old canvas and creates a new blank one. If you need to retain the image from the previous canvas you will need to copy it into the new canvas using BitmapData.copyPixels. This would be inside the createBitmap method of the BitmapRenderer.