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

    • CommentAuthorjkafkaris
    • CommentTimeOct 13th 2011
     
    Hi All,

    I'm wanting to use an instance of a Sprite as a particle but having no luck.

    For example, if I was to use the example http://flintparticles.org/tutorials/snowfall but instead of using a ImageClass I want to somehow use a sprite as the default particle.

    I've played around with createParticle2DFromDisplayObject but either I'm on the wrong track or doing something wrong.

    Can anyone help?

    Thanks.
    • CommentAuthordwightepp
    • CommentTimeOct 13th 2011
     
    This is how i did it on the pachinko example, I bet you can do something like this for the snow one.

    In your library, you'll want to right click on the movieclip you want to use. Select properties. click "export for actionscript" take note of className

    back in your emitter actionscript

    emitter.addInitializer( new SharedImage( new className() ) );
    • CommentAuthorjkafkaris
    • CommentTimeOct 13th 2011
     
    Thanks for the advice dwightepp but I'm doing this from a pure AS3 way and wanted the ability for the sprites to be changed dynamically before being used.

    I worked it out in the end - I have another class that extends sprite and has some arguments in it's constructor - I then pass values to this constructor the following way:

    _emitter.addInitializer(new ImageClass(MyParticle, ["text", 0x0072bc])); // this passes some text and a colour to be used for the particle.
    • CommentAuthorjkafkaris
    • CommentTimeOct 13th 2011
     
    just to add - the above is when using a DisplayObjectRenderer.

    you can also use a BitmapRenderer and use it this way:

    var myParticle:MyParticle = new MyParticle("text", 0x0072bc);
    _emitter.addInitializer(new SharedImage(myParticle));