A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 50

Thread: [Flash8] particles using bitmaps

  1. #1
    \x3a\x6f\x29
    Join Date
    Sep 2005
    Location
    paris
    Posts
    88

    [Flash8] particles using bitmaps

    in my eyes, the best parts of flash8 are the bitmapdata and filter methods.
    now we are able to use well-known technics that come from opengl for example in flash.

    i wanted to do some fire effect in flash.
    a year ago i developed a simple particle system in flash7. this gave me the idea of what is possible using particles. but of course they are to slow to be implemented in a game.

    http://www.je2050.de/fla.php?file=ParticleTest

    now i wanted to do some fire effect in flash8.
    the first thing that came to my mind was doing this using pixel access.
    here is an example of an old-school fire effect. it is of course very slow so it is only 50x50 px and looks not very good

    http://www.je2050.de/showroom.php?file=fire
    (mouseclick changes blendmode)

    then, there was a post on tinics blog. he also did a nice fire effect using flash8 filters

    http://www.kaourantin.net/2005/08/li...ect-using.html

    but because i really like particles i started with an idea that comes from opengl/directx whatever.

    - load a greyscale bitmap
    - colorize it
    - draw it

    a simple example with ugly textures and ugly code is

    http://www.je2050.de/showroom.php?file=bitmapfire

    and here some eyecandy and also to show the speed of this technic.
    100 particles, changing color at runtime(!!)

    http://www.je2050.de/showroom.php?file=bitmapparticles

    i think they are now fast enough to be used in games for some eyecandy :o)

    source:
    http://www.je2050.de/stuff.php?p=/source/effect/
    (fire.as is the pixel-fire and particle.as is used in the two other examples)

    btw. two things i discovered about speed:
    - it is faster to use _alpha insted of using a matrix
    - it is faster to apply a filter to a movieclip instead of a bitmap
    Last edited by joa__; 09-15-2005 at 08:27 AM.

  2. #2
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    i already told you mate,but no probs saying it here again, sweet stuff, looks and works delicious, keep it comin

  3. #3
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    Thanks joa, it seems very nice but most of the links doesn't work now. I have a "error" displayed on the last pages.

  4. #4
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    I couldnt view th elast two pages. Got "error".

    Also, is anyone else getting the Flash player installation prompt when they try and view this one?: http://www.kaourantin.net/2005/08/li...ect-using.html

    I already have 8,0,24,0 installed. Yet EVERY time I get the prompt on that page!

  5. #5
    -= phil =- d3s_inc's Avatar
    Join Date
    Oct 2002
    Posts
    610
    It is fast enough to do games... if you are careful.
    I made an engine using some pretty sick Bitmapdata usages and filters.. HOWEVER, while I would LOVE to show you guys how kick ass it is... specially since it runs at 800x600 at constant 30 fps i can't...

    Now, as it turns out, what I need to do is too much for flash, but it's definitly possible to make use of the BitmapData stuff for a crazy particle engine.

    Once I can, I will show what I mean,

    peace out mans.

  6. #6
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    i'd love to know more about particle engines with bitmapData, what i'm most interested in is dealing with multiple particles without each having an onEnterFrame, thats what slows it down the most, if i create particles with no graphics but still update positions according to different velocitys, the engine will still run slow, graphics are only a small part of the problem, its controlling the particles which is the tricky part.

    I think i heard someone metion that they used a transform matrix to control all the particles? doesn't make sense to me anyone got any idas
    lather yourself up with soap - soap arcade

  7. #7
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    well,the transform matrix is just used for applying transformations on the particles in this case. Like changing positions,scale etc. To update the whole thing you´ll still need to use enterFrame or intervals. You shouldn´t have one interval per particle object though but rather have the particles registered somewhere or just in an array and then iterate through that each frame refresh.

  8. #8
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    yeah i'm just about to do a few tests on handiling alot of movieclips, i know that for in loops don't work, so i'll figure something out
    lather yourself up with soap - soap arcade

  9. #9
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    nay,screw lots of mcs,you´d end up with way worse performance than if drawing the particles into a bmp

  10. #10
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    hang on, so i should create a loop which goes through an array and draw the particles onto a bitmap the size of my movie, so does that mean after every draw i should fill that bitmap with transparent pixels? never thought of doing it like that, hmmmm
    lather yourself up with soap - soap arcade

  11. #11
    Senior Member
    Join Date
    Mar 2003
    Posts
    316
    most of the links seem to be broken ?

  12. #12
    -= phil =- d3s_inc's Avatar
    Join Date
    Oct 2002
    Posts
    610
    hang on, so i should create a loop which goes through an array and draw the particles onto a bitmap the size of my movie, so does that mean after every draw i should fill that bitmap with transparent pixels? never thought of doing it like that, hmmmm
    Exactly.. that will give you the best performance.
    As I said, I know
    Have proof.

    The least amount of MC's the better, for the most part.
    You particles should all be updated into 1 BitmapData and all updated in 1 loop.


    Oh yeah, to clear the screen with transparent pixels, use the ColorTransform.. that messed me up for a long time. but ColorTransfrom, with an alpha multiplier of 0 will get you what you want.

  13. #13
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    Quote Originally Posted by d3s_inc
    Exactly.. that will give you the best performance.
    As I said, I know
    Have proof.

    The least amount of MC's the better, for the most part.
    You particles should all be updated into 1 BitmapData and all updated in 1 loop.


    Oh yeah, to clear the screen with transparent pixels, use the ColorTransform.. that messed me up for a long time. but ColorTransfrom, with an alpha multiplier of 0 will get you what you want.
    found a better solution, tried your way but the fact is that i have much more going on than one bitmap being drawn to and filling it in 650x650 every frame with a colorTransform or fillRect plus other things goes really slow. There's alot to think about, cloning a bitmap, keeping references of bmp's, objects and such.

    Now i use movieclips to hold the bitmaps and drawing which doesn't require a whole refresh of a 650x650 bitmap. Thanks anyway
    lather yourself up with soap - soap arcade

  14. #14
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    Quote Originally Posted by mr_malee
    Now i use movieclips to hold the bitmaps and drawing which doesn't require a whole refresh of a 650x650 bitmap. Thanks anyway
    Sounds familiar =D

    Using a huge bitmap is the worst way I can think, mainly because you need to implement dirty rects, or clean it up before you redraw. Also a large bitmap inhibits your ability to scroll.
    Christopher Rhodes
    squarecircleco.

  15. #15
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    *cough* thanks iopred, its weird tomsamson and ds3Inc both say that it'd be faster without movieclips, i'd like to see an example of this, i can understand if the bmp your drawing to and erasing is like 200x200 but not 650x650

    thansk again iopred (bloddy functions within movieclips, never again)
    lather yourself up with soap - soap arcade

  16. #16
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    Tomsamson is smoking something, he's on too tight a deadline =D

    But yeh, I can't see blitting 1000 bitmaps onto a static bitmap being faster than having flash handle it with attached movies. Flash's BitmapData functions are handy, but the cacheAsBitmap is the main gain, everything else runs slow (setPixel anyone?).

    ps. The beauty of running all your code from one frame means you don't see weird bugs like that, I think you may have found one, it sounds weird.
    Christopher Rhodes
    squarecircleco.

  17. #17
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    did you guys see this post over in the maths section regarding the v9 player;
    http://board.flashkit.com/board/showthread.php?t=689481
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  18. #18
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    Yup, makes me upset that I coded so much of my new engine in AS2, such wasted time.

    But F9 is only speeding up code execution as far as I have heard, graphics wont see the speed increase that they did from 7 -> 8.
    Christopher Rhodes
    squarecircleco.

  19. #19
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    yeah just downloaded the new player, works better in a browser than my desktop but yeah the gfx still slows it down a tad
    lather yourself up with soap - soap arcade

  20. #20
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    "But yeh, I can't see blitting 1000 bitmaps onto a static bitmap being faster than having flash handle it with attached movies"

    Hmmmm I wish I didn't have more work than God atm, 'cause I wanna try this particle thing out.
    I'm still interested to see if blitting rather than usings mc's will give the speed increase we want. I've got a feeling it may in some circumstances.

    Squize.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center