FLuNK – FLiNT Particles in FlashPunk
Posted on April 25, 2011
I started dabbling in FlashPunk and felt a need for more advanced particles, so "FLuNK" was born!
First version is guaranteed to have shortcomings (bugs etc), but it should be enough to get you started.
I've made two renderers, the EntityRenderer which shows particles as FlashPunk Entity objects, and the GraphicRenderer which draws everything in a single Graphic. Or rather, the renderer itself extends Graphic and draws upon FlashPunks BitmapData in the update method.
Obviously the GraphicRenderer is faster, but not by very much. Check out the demo for comparison. The EntityRenderer allows you to check collisions, and that's cool so you might want to use both depending on the situation.
Worth noting:
- Obviously anything 3D from FLiNT has not been accounted for.
- Since collision with rotated entities in FlashPunk is tricky in itself (just found the forum threads), this has been left alone.
- Actions/activities that regard the mouse obviously doesn't work the same (or at all).
Possible planned updates:
- Support for the simple display objects in FLiNT (RadialDot etc..).
- Support for things like Particle2DUtils.createRectangleParticlesFromBitmapData();
This is required in making exploding images and such.
- Initializers that take multiple images and weighted arrays, much like the FLiNT implementation.
Check the demo below. Download:
- FLuNK v0.2 — Only the necessary classes.
- FLuNK v0.2 — Full source of demo, including todays latest FLiNT & FlashPunk.
* This is now updated from v0.1 to v.02, sorting out a memory leak bug in the EntityRenderer. Demo below now reflects that as well.
It's a FlashDevelop project. Code is hopefully straightforward enough for you to grasp.
Read more about FlashPunk here.
Read more about FLiNT Particles here.
5 Responses to FLuNK – FLiNT Particles in FlashPunk
Very cool. I was about to start doing this myself but I think what you have here will be a good headstart. Thanks!
You're welcome!
Pretty soon after making this I (perhaps unfortunately) switched focus to Flixel, and I'm currently working on extending it for some other features. What I'm saying is that there may not be any more updates on this coming from me any time shortly.
This is very cool indeed as I just started out with FlashPunk and found it's native particle system lacking.
Curious to why you shifted to Flixel?
A few reasons:
- I wanted to learn it to compare.
- The community seemed more active.
- I wanted to see if it would solve my problems with choppy graphics, but that turned out to be Flash itself and it can't be remedied unfortunately.
- Someone made a cool displacement effect for Flixel which I wanted to take advantage of.
So far though, I see good use for both frameworks!
Hope you get some use out of FLuNK.
FLuNK is coming in very handy for my current project, thank you. I am slowly wrapping my head around how you managed it and have already created a class to have animated particles via FP's Spritemap class.
I have noticed some odd behaviors though, do you still monitor the thread on the FlashPunk forums?