Flint Particle System Forum - Automatic Clean Up2011-12-11T06:23:42+00:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1288#Comment_12882010-08-09T16:13:19+01:002011-12-11T06:23:42+00:00NickyDhttp://flintparticles.org/forum/account.php?u=325
I am working on a game project and one of the mechanics in this project entails that when a player touches a power up an effect is added to the stage using flint. To clean up the effect I am using a ...
This works fine assuming the player/user does not grab a second power up before the timer is up and the previous effect is cleaned. Is there an action or way to tell an emitter to clean itself up on its own when the last particle dies?
public var trail:Emitter2D; public var trailRenderer:BitmapRenderer; private var killTimer:Timer;
//CLEANS UP THE HEART EFFECT FROM STAGE AND MEMORY******************************************************************** //@xPos -the x position in which to draw the effect to //@yPos -the y position in which to draw the effect to public function GetHeart(xPos:Number, yPos:Number):void { var _xPos:Number = xPos + 2; var _yPos:Number = yPos + 10;
killTimer = new Timer(2600); killTimer.addEventListener(TimerEvent.TIMER, CleanGetHeart); killTimer.start(); }
//CLEANS UP THE HEART EFFECT FROM STAGE AND MEMORY******************************************************************** public function CleanGetHeart(evt:TimerEvent):void { killTimer.stop(); killTimer.removeEventListener(TimerEvent.TIMER, CleanGetHeart); killTimer = null;
Help is much appreciated. Thank you!]]>
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1289#Comment_12892010-08-09T17:04:52+01:002011-12-11T06:23:42+00:00NickyDhttp://flintparticles.org/forum/account.php?u=325
This seems to work better! The way I was calling it through the GameManager Class was incorrect. I initialized the EffectsObject once and then was trying to clean it up over itself again and again ...
//ADDS THE OBTAIN HEART EFFECT TO THE STAGE AND MEMORY******************************************************************** //@xPos -the x position in which to draw the effect to //@yPos -the y position in which to draw the effect to private function GetHeartEffect(xPos:Number, yPos:Number):void { var _xPos:Number = xPos + 2; var _yPos:Number = yPos + 10;
//CLEANS UP THE HEART EFFECT FROM STAGE AND MEMORY******************************************************************** private function CleanEmitter(evt:EmitterEvent):void { trail.removeEventListener(EmitterEvent.EMITTER_EMPTY, cleanEmitter); trail.stop(); ParticleCreator2D(trail.particleFactory).clearAllParticles(); trailRenderer.removeEmitter(trail); trail = null; removeChild(trailRenderer); trailRenderer = null; }]]>
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1290#Comment_12902010-08-10T08:25:43+01:002011-12-11T06:23:42+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Hi Nicky
I see no way to automate the clean-up within Flint since a key part of the clean-up is setting your references to the emitter and renderer to null.
The call to clearAllParticles is ...
I see no way to automate the clean-up within Flint since a key part of the clean-up is setting your references to the emitter and renderer to null.
The call to clearAllParticles is unrelated to the rest of the code, and possibly not desired. The particleFactory retains dead particles so they can be reused in other effects later. This makes the initializing of those effects slightly quicker because the particles don't need to be created.
Aside from that, your code is much like I would write.]]>
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1292#Comment_12922010-08-11T17:50:18+01:002011-12-11T06:23:42+00:00NickyDhttp://flintparticles.org/forum/account.php?u=325
Awesome thank you very much! I'll lose that line then.
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1337#Comment_13372010-09-13T08:59:13+01:002011-12-11T06:23:42+00:00Xorhttp://flintparticles.org/forum/account.php?u=381
> I see no way to automate the clean-up within Flint since a key part of the clean-up is setting your references to the emitter and renderer to null.
You don't need to keep a reference and then ...
I see no way to automate the clean-up within Flint since a key part of the clean-up is setting your references to the emitter and renderer to null.
You don't need to keep a reference and then it's possible to let the effect clean itself up. I use this in a simple effect framework that is instantiated, added to the display list and then removes itself from the list once some conditions are met. Since the display list will retain the object it will live until it removes itself. At that point there are no more references and the garbage collection can take care of it.
Of course, if you want to still interact with the effect you'll need to keep a reference and null it when it's time to let it go.]]>
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1352#Comment_13522010-09-16T08:12:02+01:002011-12-11T06:23:42+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Absolutely. The display list keeps a reference to the renderer. The renderer keeps a reference to the emitter. The emitter keeps a reference to the actions. etc. Remove the renderer from the display ...
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1562#Comment_15622011-02-26T19:06:04+00:002011-02-26T19:07:35+00:00killerspazhttp://flintparticles.org/forum/account.php?u=474
I have a similar question, however I am already doing everything as described in this thread (with the exception of the call to clearAllParticles()).
I'm playing with a fun environment where the ...
I'm playing with a fun environment where the user can click on the renderer, and explosions occur. There could be as many explosions as the user desires at any given time.
My approach is to create a new emitter per click, position it based on mouse coords, and start it up. My issue is that i have a BlurFilter applied to the renderer (BitmapRenderer), and upon an EMITTER_EMPTY, i still have artifacts from a blurred emitter on the renderer.
I can't for the life of me figure out a good way to clean this up!
I don't want to remove the filter or do anything drastic, as the user can start another emitter up around the time a pre-existing emitter is expiring. But if the emitter is stopped or removed, it seems the renderer stops executing filters.
If i don't remove the emitter, clearly performance drops quickly as the pre-existing emitters are constantly dispatching that they're empty. I am going to move it to a pooled emitter system, but with just a single emitter active, this doesn't solve the issue.
Any help?]]>
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1563#Comment_15632011-02-27T00:56:53+00:002011-12-11T06:23:42+00:00killerspazhttp://flintparticles.org/forum/account.php?u=474
OK I managed to find a work around.
Since my situation doesn't really have a lot of overhead, and isn't a game - I found it useful to have the renderer executing non stop.
The way I did this ...
Since my situation doesn't really have a lot of overhead, and isn't a game - I found it useful to have the renderer executing non stop.
The way I did this was adding a bogus emitter:
//Add a bogus emitter to force renderer to continue working. var bogusEmitter:Emitter = new Emitter(); bogusEmitter.counter = new ZeroCounter(); bogusEmitter.start(); this._renderer.addEmitter(bogusEmitter);
This way the renderer is still listening for Event.RENDER because it still has an emitter in it. This emitter just happens to do nothing. I suppose this is akin to say a game loop, I want the "game" engine to run forever.. In my case, it's just a BlurFilter on the renderer.
Now while this satisfies my situation, I'm curious what the more appropriate approach would be for say someone doing a game where an explosion might occur, and blurring is utilized for effect. Would they just do something (which i was trying to avoid) cheezy and just say "ok after 5 seconds finally remove the emitter?" I wanted something a bit more accurate, but the ONLY thing I could think of was analyzing pixel data in the bitmap, which i would assume to be pretty slow in between each filter apply. And even still, that'd be more logic I'd have to write that I just don't care to do right now.]]>
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1568#Comment_15682011-02-27T13:34:38+00:002011-12-11T06:23:42+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Your cheezy solution is possibly the most practical - that or the solution you have come up with. One other option that comes to mind is to use one emitter for all the explosions. Using a blast ...
Automatic Clean Uphttp://flintparticles.org/forum/comments.php?DiscussionID=381&Focus=1570#Comment_15702011-02-27T21:35:25+00:002011-03-02T16:23:38+00:00killerspazhttp://flintparticles.org/forum/account.php?u=474
Well if I have an emitter already running, and then update the position initializer, wouldn't I also be overriding the existing coutner object? I haven't looked into the source to see if it's a ...