Hi guys,
I don't necessarily have a question here, just explaining some tests that
I've done and seeing if anyone has input/ideas that I've missed.
I've been experimenting a bit with particle effects. In an effort to
determine the new "best way" to approach this I've created a test the old
way (attaching movie clips), and the new way (using BitmapData).
Unfortunately, the old movie clip way still performs better, that-is when
used in conjunction with cacheAsBitmap.
I've seen some F8 particle effect demos online where particles are
continually added, but not moved or removed. In that scenario I think
BitmapData works well because you are just adding to an image. However, if
you want to have a trail of sparks shooting out of something and affected by
gravity or other dynamic forces, then you are not continually adding to an
image..it must essentially be redrawn every time. My approach to this using
BitmapData was as follows:
- Made a particle class that will store the BitmapData instance for a given
particle, and its other associated properties, like x and y psotion, speeds,
translation matrix, etc
- Generate about 5 of these things per frame (using clone() on the initial
particle BitmapData). They get removed after a lifetime.
- Every frame I wipe the screen clean, draw a base black square (using new
BitmapData), loop through an array of Particle class instances and draw()
them to the base square. I use Matrix.translate with draw() to position the
particle data to where it needs to be
In this approach there is only 1 movie clip. The array is cleaned up
properly. As far as I can tell there are no memory issues. But the end
result is much slower performance than the equivalent done with movie clips
and cacheAsBitmap. So I'm wondering if anyone sees a theoretical flaw here
or can suggest an alternative approach?
Right now my thinking is that the best approach to particle effects in Flash
(where the particles actually move) is going to require at least 1 movie
clip per particle. I'd like to be wrong, so if someone could tell me why ...
Jobe Makar
http://www.electrotank.com
http://www.electro-server.com
phone: 919-609-0408
mobile: 919-610-5754
fax: 919-341-8104
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders